MVC 3 + EF 4.1
I'm choosing between two approaches to deal with DbContext:
- Instantiate in
Application_BeginRequest, put it intoHttpContext.Current.Itemsand dispose inApplication_EndRequest. - Create disposable UnitOfWork (kindof wrapper for
DbContext) and start each controller action withusing(var unitOfWork = new UnitOfWork()) { ... }
Share your experience please: Which one would you prefer? what are pros and cons for each approach?