开发者

bug in EF 4.0 after disconnected from remote SQL server?

I find the EF 4.0 would throw an exception "An existing connection was forcibly closed by the remote host" after the web server disconnected from remote sql server and re-connect with it. for example,I write the below code:

using (SparePartEntities aa = new SparePartEntities())
{开发者_如何学Go
  var bb = aa.TS_SYS_User.ToArray();
}

firstly, i run the code in web page and the result is ok.

Then I disconnect the network connection and reconnect it.

When i refresh the asp.net page, an exception would be thrown "An existing connection was forcibly closed by the remote host".

I find it would be OK in EF 1.0? What's wrong?


That is not a bug in EF. That is well known behavior when using connection pooling. The problem is that connection pool holds opened connections which are reused for subsequent database access. But if you disconnect from the network these connections will be faulted. Next usage of that connections will throw the mentioned exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜