其他分享
首页 > 其他分享> > System.InvalidOperationException: Unexpected connection state. When using a wrapping provider ensure

System.InvalidOperationException: Unexpected connection state. When using a wrapping provider ensure

作者:互联网

System.InvalidOperationException: Unexpected connection state. When using a wrapping provider ensure that the StateChange event is implemented on the wrapped DbConnection.

System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.TimeoutException: Timeout in IO operation

开发项目在使用EF6遇到的坑!

1、有时候调试停个一两分钟,然后继续调试可能就会出现这个错误,然后无法连接数据库。

2、其它未知错误也可能会引发该错误。

解决办法:创建一个新的DbContext即可解决

try{

     //你执行的代码。。。。。

}catch(System.InvalidOperationException inverr)

{

    //Creating a new db-context solved the problem.

   //创建一个新的DbContext即可解决

}

 

标签:Unexpected,StateChange,DbConnection,When,System,provider,InvalidOperationExcepti
来源: https://www.cnblogs.com/pzxnet/p/13094340.html