Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
785 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...