如何在aspnetcore/entityframeworkcore中设置命令超时

编程入门 行业动态 更新时间:2024-10-19 07:36:49
本文介绍了如何在aspnetcore/entityframeworkcore中设置命令超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

设置命令超时的位置不再与早期版本相同.

但是,我找不到任何地方说明如何更改此内容.

我正在做的是上传非常大的文件,该文件的保存时间超过了默认的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中设置命令超时

本文发布于:2023-11-14 09:39:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586862.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   如何在   aspnetcore   entityframeworkcore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!