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

前端 未结 2 1761
北海茫月
北海茫月 2021-01-05 14:19

After some use in qa we get the following error

Execution of the command requires an open and available connection. The connection\'s current state is broken.<

2条回答
  •  迷失自我
    2021-01-05 14:54

    I think it's wastefull to create a new contectObject for each Dal operation

    Do you have any evidence for this? I believe that Entity Framework and indeed most data access frameworks are designed for lots of short-lived and independent contexts. Implementing your own pooling / caching here is usually an anti-pattern, possibly resulting in stale results, concurrency issues, and poor failure recovery (as is the case here).

    What specific resources do you think will be wasted, and have you validated this experimentally?

    Basically, I would suggest creating a fresh context for each unit of work (may well correspond roughly to a request) - measure any performance differences, and see whether the problem goes away (as I expect it will). As part of your testing, occasionally disconnect the database server from the network to check that you can actually recover, too...

提交回复
热议问题