我正在使用asp.net mvc 5中的实体框架,并且sql server非常慢,所以每当我尝试访问连接到Db的页面时,我都会收到以下错误: -
Server Error in '/' Application.
--------------------------------------------------------------------------------
The wait operation timed out
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The wait operation timed out
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
但我找不到增加实体框架类内部超时的方法? 我在web.config中的连接字符串如下所示: -
<add name="***Entities" connectionString="metadata=res://*/Models.Model2.csdl|res://*/Models.Model2.ssdl|res://*/Models.Model2.msl;provider=System.Data.SqlClient;provider connection string="data source=*******;initial catalog=TMSres;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
如何增加实体框架与实时框架之间的超时会话Sql Server?
Thnaks
答案 0 :(得分:2)
您可以按
进行设置// Specify a timeout for queries in this context, in seconds.<br>
context.CommandTimeout = 120;