设置命令超时的位置不再与早期版本相同.
但是,我找不到任何地方说明如何更改此内容.
我正在做的是上传非常大的文件,该文件的保存时间超过了默认的30秒.
请注意,我询问的是命令超时,而不是其他问题.
解决方案如果使用DI容器管理DbContext(即,将DbContext添加到服务集合中),则可以在以下命令中指定命令超时:选项.
在Startup.ConfigureServices中:
services.AddDbContext<YourDbContext>(options => options.UseSqlServer( this.Configuration.GetConnectionString("YourConnectionString"), sqlServerOptions => sqlServerOptions.CommandTimeout(60)) );The place where the command timeout is set is no longer the same as earlier versions.
However, I cannot find anywhere that says how to change this.
What I am doing is uploading very large files which takes longer than the default 30 seconds to save.
Note that I ask about Command Timeout, not Migration Timeout as in another question.
解决方案If you're using the DI container to manage the DbContext (i.e. you're adding the DbContext to the service collection), the command timeout can be specified in the options.
In Startup.ConfigureServices:
services.AddDbContext<YourDbContext>(options => options.UseSqlServer( this.Configuration.GetConnectionString("YourConnectionString"), sqlServerOptions => sqlServerOptions.CommandTimeout(60)) );
更多推荐
如何在aspnetcore/entityframeworkcore中设置命令超时
发布评论