views:

25

answers:

1

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 threw the error:

INTERNAL ERROR: Execution of the command requires an open and available connection. The connection's current state is broken.

Not being very proficient in EF I'm not aware of how I could recover from such a scenario, and why it occurred in the first place? Anyone had this happen before?

+2  A: 

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.

Hightechrider
Ohhh.. So I can't reuse them. -_-
Jonn