Migrate from System.Data.SqlClient to Microsoft.Data.SqlClient #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to support newer authentication methods such as Azure Managed Identities we're looking to migrate to the new SqlClient library. Unfortunately there's no direct compatibility here and changes to manipulations lib are necessary.
In this PR is the simplest change of migrating from one package over to the other.
Is it possible to support both?
For the most part there are 2 points of incompatibility I saw before I started making changes:
System.Data.SqlClient.SqlConnectionBuilder
was used to retrieve metadata for cache key when adding a new Type for TableValuedParameter. It can be remedied by modifying the connection string before passing it toSqlConnection
and removing those spaces for a select few fields (see changed fields).SqlParameter
from the packages - if you want to support both packages at the same time you need to be able to choose whichSqlParameter
to instantiate depending on the connection type.I was able to get a decent fix in
ToSqlCommand()
extension method (below) but inSqlCommandBuilderExtensions.CreateTableValuedParameter
we don't get it as easily.