-
Notifications
You must be signed in to change notification settings - Fork 292
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
MultipleActiveResultSets spelled wrong from SqlConnectionStringBuilder.ConnectionString #654
Comments
I think the bug is there: SqlClient/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionStringCommon.cs Line 1093 in 2b40206
in this PR: #534 (i am not sure) |
Oh, i missed a key piece of information: This is not backward compatible with (pretty much legacy, i know, but what can i do...) LinqToEntity - it throw |
@SPLITE Can you show the stack trace from your exception? |
🤦♂️ oh my... After closer inspection i am almost sure this is my bug (i am passing connection string where i should pass connection) - please give me few minutes to validate (how it could ever work...), then i will probably close this issue. |
Well, closing. I am sorry i bothered you 😊 This whole thing is my mistake. For random googlers, there is what happened: In our (really old) project, we use System.Data.Linq.DataContext (that is not Entity Framework, that is Entity Framework ancestor 🙂) which can be constructed with IDbConnection or connectionString or even file name. Of course, everything work when you do something like new System.Data.Linq.DbContext(
new Microsoft.Data.SqlConnection(
new Microsoft.Data.SqlConnectionBuilder(connectionString).ConnectionString
)
) (please dont do this, this is only example). But there was one service where that new System.Data.Linq.DbContext(
Microsoft.Data.SqlConnectionBuilder(connectionString).ConnectionString // this is wrong.
) only. And I did not notice... I was sure that I was sending connection and not connectionString. With dotPeek i found out this will auto-create System.Data.SqlClient - and this accidentally worked until "MultipleActiveResultSets" was changed to "Multiple Active Result Sets". |
Version: Microsoft.Data.SqlClient 2.0.0; .net47 (NuGet)
If i set MARS on
Microsoft.Data.SqlConnectionstringBuilder
totrue
then propertyConnectionString
will return"Multiple Active Result Sets=true;"
which is wrong - there are spaces, it should be"MultipleActiveResultSets=true;"
(see https://docs.microsoft.com/en/dotnet/framework/data/adonet/sql/enabling-multiple-active-result-sets, https://www.sqlteam.com/articles/multiple-active-result-sets-mars, https://www.connectionstrings.com/microsoft-data-sqlclient/enable-mars/ etc)Packages.config (fresh console project with Microsoft.Data.SqlClient nuget):
Issue reproduction:
or
(connection string is from https://www.connectionstrings.com/microsoft-data-sqlclient/enable-mars/)
Can post you repro, but its really just these few lines of code.
Workaround:
a) Dont update to 2.0.0 :)
b) just
cb.ConnectionString.Replace("Multiple Active Result Sets", "MultipleActiveResultSets");
The text was updated successfully, but these errors were encountered: