As a static context for Entity Framework

asp.net entity-framework

Question

In a web application it would be ok if i declare the context of a entity framework model as static? it would be ok? its not recommended? why? Thanks!

1
33
5/20/2009 2:15:56 PM

Popular Answer

Almost definitely not.

ObjectContexts get bigger and bigger as more Objects are queried / saved.

Also sharing an ObjectContext between threads, as you would be doing, is not recommended, because of the locking issues and undeterministic side-effects you would have to deal with.

I wrote a tip on this topic a while back.

Tip 18 - How to decide on a lifetime for your ObjectContext

34
5/20/2009 4:18:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow