2014-02-12 14:52:37
Create a private instance of your DBContext.
Within the controller constructor instantiate your DBContext.
Override the controllers Dispose method and dispose of your DBContext.
public class CustomerController : Controller
{
private ApplicationDbContext _context;
public CustomerController ()
{
_context = new ApplicationDbContext();
}
protected override void Dispose(bool disposing)
{
_context.Dispose();
}
}