EF recovery from invalidoperationexception caused by server being down

后端 未结 2 1285
無奈伤痛
無奈伤痛 2020-12-21 21:30

I had a windows service relying on EF, and it was running fine until the server went down. The problem was after the server went up again, it didn\'t fix itself and still t

相关标签:
2条回答
  • 2020-12-21 22:16

    What is the lifetime of your ObjectContext? If you are using a single ObjectContext for the lifetime of your service that would cause problems like this. You should instead scope the ObjectContext lifetime down to a smaller window of time, creating a new one for each unit of work.

    0 讨论(0)
  • 2020-12-21 22:17

    Solution described here worked for me, modify the connection timeout in your connection string

    FROM server='MySQLServer'';Integrated Security=true;Initial Catalog='EVConfiguration';Connection Timeout=100 TO server='MySQLServer';Integrated Security=true;Initial Catalog='EVConfiguration';Connection Timeout=0

    0 讨论(0)
提交回复
热议问题