gpt4 book ai didi

c# - 连接字符串中的 MultipleActiveResultSets 是什么意思?

转载 作者:行者123 更新时间:2023-12-04 11:01:33 27 4
gpt4 key购买 nike

我想了解 Multiple Active Result Sets 我已经阅读了 Microsoft 文档,但是如果您可以添加一些有关 MultipleActiveResultSets 的示例,我不是很了解。

When MARS is enabled for use with SQL Server, each command object usedadds 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...

关于c# - 连接字符串中的 MultipleActiveResultSets 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58769812/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com