Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 增加实体框架中的命令超时限制_C#_.net_Entity Framework - Fatal编程技术网

C# 增加实体框架中的命令超时限制

C# 增加实体框架中的命令超时限制,c#,.net,entity-framework,C#,.net,Entity Framework,我不熟悉实体框架(和MVC)。我的一个模块将数据加载到网格需要50秒以上。网页超过30秒时超时 理想的方法是微调存储过程,因为返回结果需要50秒以上的时间。我希望将超时限制从默认的30秒增加到至少1分钟 我尝试了以下方法,但没有成功: 1. I have set the connection timeout at web.config file but it is not working 2. I tried something like this public ApplicationDbC

我不熟悉实体框架(和MVC)。我的一个模块将数据加载到网格需要50秒以上。网页超过30秒时超时

理想的方法是微调存储过程,因为返回结果需要50秒以上的时间。我希望将超时限制从默认的30秒增加到至少1分钟

我尝试了以下方法,但没有成功:

1. I have set the connection timeout at web.config file but it is not working

2. I tried something like this

public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
{
      Database.SetCommandTimeout(9000);
}
1。我已经在web.config文件中设置了连接超时,但它不起作用
2.我试过这样的东西
公共应用程序DBContext(DbContextOptions选项)
:基本(选项)
{
SetCommandTimeout(9000);
}
当我通过VisualStudio运行解决方案时,第二种方法效果很好,但当我在服务器中部署相同的代码时,这种方法不起作用

我认为在部署期间需要在服务器级别更改一些配置,但我不确定


谁能帮我一下吗。在过去的两天里,我一直在发疯,但运气不好。

它可能被web服务器覆盖了

在IIS中,它是在网站配置中设置的:
高级设置>行为>限制>连接超时(秒)


其他web服务器上应该有类似的功能。

优化您的过程您使用的数据库连接。您可以添加连接超时属性以增加db连接的长度。ASP.NET、MVC或非MVC不处理数据访问。这是一个实体框架问题。但是,您没有提供任何相关信息,没有数据访问代码、查询或存储过程,因此无法提供帮助您的数据访问代码做什么?您是否正在使用事务,使其保持打开状态的时间过长?那个存储过程是做什么的?你是不是在妨碍自己?如何调用存储过程?
SqlCommand
对象本身有一个
Timeout
属性有许多可能的超时。你得到了哪一个确切的例外?