So we have this web service that uses an homemade data access framework and I found that that in its current state, the web service cannot run more than one instance at a time because this framework will start stepping on its own feet and whine about connections being closed/already opened and error like that.
So I implemented an SQL lock/mutex that queues all requests and since then, it’s been pretty smooth.
I recently worked for another project which uses the ADO Entity Framework (which I’ve never played with until then) and found out it pretty much does what this homemade framework does.
My question is, is the ADO Entity Framework robust enough on its own so I would not need this SQL mutex implementation anymore ?
Thanks.
If you will follow the rule “Do not share ObjectContext (DbContext in code first) instances between threads”, everything will be ok.
Entity framework uses some static data to improve performance (entity model cache), but most of objects (entity connections, contexts, change trackers, etc.) are not thread-safe and shouldn’t be shared between threads.