Reputation: 430
I would like to know about Multiple Active Result Sets I have read Microsoft documentation, but I didn't understand it very well if you can add some example about MultipleActiveResultSets.
When MARS is enabled for use with SQL Server, each command object used adds a session to the connection. I didn't understand it.
In general, When should I use "MultipleActiveResultSets" in the connection string?
For instance, I have used this code for the Migrating database, but I got me some error.
Keyword not supported: "MultipleActiveResultSets"
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
using(var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<DataContext>();
context.Database.Migrate();
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occured during migration.");
}
}
host.Run();
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings":{
"DBConnection": "server=.;database=ReactivityDB;MultipleActiveResultSet=true;Trusted_Connection=True"
}
}
Upvotes: 3
Views: 7485
Reputation: 81655
According to your error message:
Keyword not supported: 'multipleactiveresultset'
and your connection string:
...database=ReactivityDB;MultipleActiveResultSet=true...
that keyword should be in plural form:
...database=ReactivityDB;MultipleActiveResultSets=true...
Upvotes: 3