-
Notifications
You must be signed in to change notification settings - Fork 317
Description
Describe the bug
There is a significant discrepancy between the two SqlConnectionStringBuilder types as far as their internal keywords are defined.
The keywords can be found in the internal class DbConnectionStringKeywords. An example:
SqlClient/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
Line 1039 in 04db1a4
| internal const string TrustServerCertificate = "Trust Server Certificate"; |
However, in the .NET Framework version of the System.Data.SqlClient, the same keywords class has it defined differently:
https://referencesource.microsoft.com/System.Data/R/6a6a501b9f709c06.html
This is an example keyword, but there are more keywords where this is an issue.
Here's the code excerpt for both:
Microsoft.Data.SqlClient
...
internal const string TrustServerCertificate = "Trust Server Certificate";
...System.Data.SqlClient
...
internal const string TrustServerCertificate = "TrustServerCertificate";
...When a connection string is built using the Microsoft.Data.SqlClient.SqlConnectionStringBuilder, it cannot be deconstructed within the System.Data.SqlClient.SqlConnectionStringBuilder as it throws an exception indicating that the keyword is not supported.
To reproduce
Run the following code in a project that is using Microsoft.Data.SqlClient:
var csb = new SqlConnectionStringBuilder { TrustServerCertificate = true };
var cs = csb.ConnectionString;Take the connection string from that and then apply it to a different set of code using the System.Data.SqlClient:
var connectionString = "Trust Server Certificate=True";
var csb = new SqlConnectionStringBuilder(connectionString);
var cs = csb.ConnectionString;The following exception will occur:
System.ArgumentException: 'Keyword not supported: 'trust server certificate'.'
Expected behavior
I would expect that the keywords would match and thus the connection strings would be interchangeable.
Further technical details
N/A
Additional context
N/A