I have the following code using Dapper.SimpleCRUD :
var test = new FallEnvironmentalCondition[] { new FallEnvironmentalCondition {Id=40,FallId=3,EnvironmentalConditionId=1}, new FallEnvironmentalCondition {Id=41,FallId=3,EnvironmentalConditionId=2}, new FallEnvironmentalCondition {Id=42,FallId=3,EnvironmentalConditionId=3} }; test.ToList().ForEach(async x => await conn.UpdateAsync(x));
With this code, I am getting following exception:
InvalidOperationException: The connection does not support MultipleActiveResultSets
I don't understand I am await
ing each update so why am I getting this error.
Note: I have no control on the connection string so I can't turn MARS on.
You need to add attribute MultipleActiveResultSets
in connection string and set it to true to allow multiple active result sets.
"Data Source=MSSQL1;" & _ "Initial Catalog=AdventureWorks;Integrated Security=SSPI;" & _ "MultipleActiveResultSets=True"
Read more at: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/enabling-multiple-active-result-sets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With