-
Notifications
You must be signed in to change notification settings - Fork 308
SqlConnectionStringBuilder deviation in behavior for MultipleActiveResultSets #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @aarondandy Mixing drivers like that is not correct approach as they're different products. If you want to provide connection string to System.Data.SqlClient, you need to fetch it from the same driver. |
WorkaroundsIt'll do... // from https://github.com/dotnet/SqlClient/blob/master/release-notes/2.0/2.0.0.md#new-connection-string-property-synonyms
private static readonly (string @new, string old)[] SqlPropertyRenames = new (string, string)[]
{
("Application Intent", "ApplicationIntent"),
("Connect Retry Count", "ConnectRetryCount"),
("Connect Retry Interval", "ConnectRetryInterval"),
("Pool Blocking Period", "PoolBlockingPeriod"),
("Multiple Active Result Sets", "MultipleActiveResultSets"),
("Multi Subnet Failover", "MultiSubnetFailover"),
("Transparent Network IP Resolution", "TransparentNetworkIPResolution"),
("Trust Server Certificate", "TrustServerCertificate")
};
public static string NormalizeToLegacyConnectionString(string connectionString)
{
if (!string.IsNullOrWhiteSpace(connectionString))
{
foreach (var replacement in SqlPropertyRenames)
{
connectionString = connectionString.Replace(replacement.@new, replacement.old, StringComparison.OrdinalIgnoreCase);
}
}
return connectionString;
} |
I understand but this is still a reality for those of us using tools in this ecosystem and as the ecosystem makes this transition. Is there at least a way to get a list of connection string "keywords" that have changed between these libraries? If the burden of compatibility falls to users that would be a big help to us. |
Yes, they're documented here: You may use them for transition period! |
Awesome, thanks. I'll update my horrible workaround! |
Closing in light of above discussions. |
@cheenamalhotra Sorry, I don't follow how to use the workaround? Could you give an example? |
Where you may have code similar to |
@aarondandy Thanks, that makes sense now. |
…nt to Microsoft.Data.SqlClient. Added support for legacy connection strings based on "dotnet/SqlClient#811".
….SqlClient to Microsoft.Data.SqlClient. Added support for legacy connection strings based on "dotnet/SqlClient#811"." This reverts commit 7c673ac.
Describe the bug
I am using
SqlConnectionStringBuilder
to generate my connection strings for different database connections at run-time. For some usages I have older System.Data code (DbUp in this case) that consumes these generated connection strings. When connection strings are generated byMicrosoft.Data.SqlClient.SqlConnectionStringBuilder
it adds extra spaces toMultipleActiveResultSets
making itMultiple Active Result Sets
which is not compatible with the older System.Data versions of the library.Note: these stack traces are for System.Data.SqlClient.SqlConnectionStringBuilder and System.Data.SqlClient.SqlConnection to show the incompatibility
To reproduce
References:
System.Data.SqlClient 4.8.2
Microsoft.Data.SqlClient 2.1.0
Expected behavior
I expect Microsoft.Data.SqlClient.SqlConnectionStringBuilder to produce a connection string where "MultipleActiveResultSets" does not have extra spaces added to it
Further technical details
Microsoft.Data.SqlClient version: 2.1.0
.NET target: netcoreapp3.1
SQL Server version: N/A
Operating system: Reproduced on Windows 19041.630 and Azure PaaS Linux Hosts
Additional context
Possibly related to #654
The text was updated successfully, but these errors were encountered: