cs0815
cs0815

Reputation: 17428

EF 6 plus several db contexts

Looking at questions like this I am inclined not to use several dbcontexts. However, it would still be nice to have a look at some example code. Is anyone aware of an enterprise level open source implementation (c#) that uses several dbcontexts and unit of work (and potentially asp.net mvc)?

Upvotes: 3

Views: 848

Answers (1)

Matt Caton
Matt Caton

Reputation: 3503

As you have used the word Enterprise I would point you at Julie Lerman, who has some nice coverage of multiple DbContexts from the perspective of DDD bounded contexts.

Heres a relatively recent MSDN article she's written on this subject: http://msdn.microsoft.com/en-us/magazine/jj883952.aspx.

She also has a fantastic series of screencasts on Pluralsight that cover enterprise use of Entity Framework, including the use of multiple contexts. I wont include any links as this is a paid-for service.

From a code sample perspective, take a look at the reference CQRS architecture on the Microsoft Patterns & Practices which uses bounded contexts (as multiple DbContexts) to decompose a complex system into separate domains. http://msdn.microsoft.com/en-us/library/jj554200.aspx

The code for the reference CQRS architecture is here: https://github.com/mspnp/cqrs-journey-code.

Hope some of this proves useful to you.

Upvotes: 5

Related Questions