Unity Lifetime Managers & EF Data Context --> Best Practice

asp.net-mvc-4 dependency-injection entity-framework httprequest unity-container

Accepted Answer

Of course, you want one DbContext for each request.

The standard methods for handling this are a PerHttpRequestLifetimeManager or a child container produced on each request.

The ASP.NET MVC bootstrapper for Unity, a new version of the Unity with an integrated lifetime management, is introduced in the most recent release:PerRequestLifetimeManager .

The third chapter, Unity and Dependency Injection, of Unity Developer's Guide for Dependency Injection has further information.

10
8/16/2013 1:49:16 AM


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