Entity Framework and Per web request

May 1, 2010 at 11:21 AM
Edited May 1, 2010 at 11:58 AM

Hi,

I am using Repository pattern with inject Entity Framework generated object.

And I am using PerWebRequest life time manager explained in there : http://weblogs.asp.net/rashid/archive/2009/02/15/asp-net-mvc-unity-and-common-service-locator.aspx

Some times, I mean not often I got an error : The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

And sometimes (especially first start) : ExecuteReader requires an open and available Connection. The connection's current state is closed.

 

Is there a life time manager like that (Per web request) in Unity 2.0.   I guess PerResolveLifetimeManager  is the new one ?

Or do you know any better way to manage instance of Entity framework Or NHibernate object. (with repository pattern.)

 

Thanks.