title: When does a DbContext instance get disposed in ASP.NET Core 5
body: <p>I'm using the recommended approach to create <code>DbContext</code> instance through dependency injection.</p>
  <p>In Startup.cs -</p>
  <pre><code>services.AddDbContext&lt;DashboardContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString(&quot;DashboardConnection&quot;)));
  </code></pre>
  <p>and in the Controller -</p>
  <pre><code>private readonly DashboardContext db;
  public AccountController(DashboardContext context)
  {
      db = context;
  }
  </code></pre>
  <p>What I want to know is when this instance gets disposed.</p>
  <p>Previously we would always use the <code>using</code> statement which would dispose on close of braces -</p>
  <pre><code>using (DashboardContext db = new DashboardContext())
  {
      // Query
  }
  </code></pre>