连接字符串中的 MultipleActiveResultSets 是什么意思?
What does MultipleActiveResultSets in connection string?
我想了解 Multiple Active Result Sets 我已经阅读了 Microsoft 文档,但我不是很了解,如果您可以添加一些有关 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.
一般来说,什么时候应该在连接字符串中使用“MultipleActiveResultSets”?
例如,我已经将这段代码用于迁移数据库,但出现了一些错误。
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"
}
}
根据您的错误信息:
Keyword not supported: 'multipleactiveresultset'
和您的连接字符串:
...database=ReactivityDB;MultipleActiveResultSet=true...
该关键字应为复数形式:
...database=ReactivityDB;MultipleActiveResultSets=true...
我想了解 Multiple Active Result Sets 我已经阅读了 Microsoft 文档,但我不是很了解,如果您可以添加一些有关 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.
一般来说,什么时候应该在连接字符串中使用“MultipleActiveResultSets”?
例如,我已经将这段代码用于迁移数据库,但出现了一些错误。
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"
}
}
根据您的错误信息:
Keyword not supported: 'multipleactiveresultset'
和您的连接字符串:
...database=ReactivityDB;MultipleActiveResultSet=true...
该关键字应为复数形式:
...database=ReactivityDB;MultipleActiveResultSets=true...