I'm using the recommended approach to create DbContext instance through dependency injection.
In Startup.cs -
services.AddDbContext<DashboardContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DashboardConnection")));
and in the Controller -
private readonly DashboardContext db;
public AccountController(DashboardContext context)
{
db = context;
}
What I want to know is when this instance gets disposed.
Previously we would always use the using statement which would dispose on close of braces -
using (DashboardContext db = new DashboardContext())
{
// Query
}
SaveChangesbefore exiting the action.