title: Where is a good place to dispose of the SqlConnection object created in AddDbContext? (.Net Core 2.2)
body: <p>I am trying to get Azure's Managed Identity authentication to work with my app that I will be deploying on Azure App Service to connect to an Azure SQL Server.</p>
  
  <p>After looking through some examples and sample code I am attempting the following implementation:</p>
  
  <pre><code>services.AddDbContext&lt;MainContext&gt;(optionsBuilder =&gt;
  {
      SqlConnection connection = new SqlConnection();
      connection.ConnectionString = Configuration.GetConnectionString("DefaultConnection");
      connection.AccessToken = (new AzureServiceTokenProvider()).GetAccessTokenAsync("https://database.windows.net/").Result;
  
      optionsBuilder.UseSqlServer(connection);
  });
  </code></pre>
  
  <p>Where would be the right place to dispose of this SqlConnection? Is there a better way to implement this AccessToken set up?</p>