【问题标题】:what can cause a timeout in Entity Framework什么会导致实体框架超时
【发布时间】:2012-06-16 02:43:55
【问题描述】:

我有其他查询使用相同的连接字符串;服务器正在返回这些调用的数据。

一些设置: Connection.ConnectionTimeout = 3600(在调试器中) 数据库超时设置为 0

<add
   name="StuffEntities"
   connectionString="metadata=res://*/DataModel.Stuff.csdl|res://*/DataModel.Stuff.ssdl|res://*/DataModel.Stuff.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=10.0.1.Stuff;initial catalog=Stuff;persist security info=True;user id=Stuff;password=Stuff;multipleactiveresultsets=True;App=EntityFramework;Connect Timeout=3600&quot;"
   providerName="System.Data.EntityClient" />

外部异常

{"执行命令定义时发生错误。见 详细信息的内部异常。"}

内部异常

{"超时时间已过。在完成之前的超时时间已过 操作或服务器没有响应。”} 错误代码: -2146232060

看起来它会在 30 秒内发生。

我不知道是什么覆盖了我的设置。

【问题讨论】:

  • 您是否尝试过检查生成的 sql 以帮助发现问题?有几个选项可用,SQL Profiler、MiniProfiler 等。

标签: c# sql-server entity-framework-4


【解决方案1】:
context.CommandTimeout = 3600;

忘记换那个了。

我真傻。

【讨论】:

  • 这不是修复。这就像用绿色防水布覆盖草坪使草坪更绿。为什么不首先解决查询耗时超过 30 秒的问题?
  • 一次拉太多图片;大部分时间都很好,但通过 wifi 就很难过。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-19
  • 2011-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多