In the new MVC-5 template there's a file at the App_Start folder called Startup.Auth.cs which contains this lines (along with some other data):
// Configure the db context and user manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
What does a single instance per request meen? and what is the difference between calling the ApplicationDbContext like this:
var context = HttpContext.GetOwinContext().Get<ApplicationDbContext>();
and placing this declaration as a field in the Controller class:
public class HomeController : Controller
{
private ApplicationDbContext context = new ApplicationDbContext();
Is there a preferred approach for handling the context? is a singleton class providing the context preffered?