Hi,
To be honest, I don't know if what I proposed is available for the framework Entity framework 4.1 but it works for Entity Framework Code First.
"Each of the components need to interact with the database independent from other components. I am wondering
what is the better way to setup the context instance/s for each component. Here are some of the options"
So I recommand you to read http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
To this link a abstract layer has been defined between controller and database context.
Associate with the Unit of Work Pattern it permit to use multiple repositories by sharing the single database context.
And the concurrency is talked on the link http://www.asp.net/entity-framework/tutorials/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application
1> Have one instance of the the context used by all components. --> I think this is the worst as it
creates many concurrency issues?
I don't know if you have any question of performances. But I worked to implement a singleton pattern in WCF context to permit to share the context used by differents components and in that case, the performances are really weak. All children process
wait until the singleton is release.
2> Give every component an independent instance of the context.
http://blogs.msdn.com/b/adonet/archive/2011/02/03/using-dbcontext-in-ef-feature-ctp5-part-9-optimistic-concurrency-patterns.aspx
I hope these links will help you.
Best regards,
Alexandre
Best regards, Alexandre Barault http://alexandrebarault.wordpress.com