EF recovery from invalidoperationexception caused by server being down

后端 未结 2 1297
無奈伤痛
無奈伤痛 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.

提交回复
热议问题