title: How to use Using block when DbContext has a DbContextOptionsBuilder Parameter
body: <p>When I start my application in the Startup.cs file, I have to pass my connection string that is from my appsettings file to my DbContext like this:</p>
  
  <pre><code>services.AddDbContext&lt;ManagementStudioDbContext&gt;(options =&gt; options.UseSqlServer(Configuration["DatabaseConfiguration:ConnectionString"]));
  </code></pre>
  
  <p>In my ContextFactory class where my DbContext is created, it passes a DbContextOptionsBuilder variable to my DbContext as well like this:</p>
  
  <pre><code>public ManagementStudioDbContext CreateDbContext(string[] args)
  {
      //Debugger.Launch();
      IConfigurationRoot configuration = new ConfigurationBuilder()
      .SetBasePath(ConfigurationManager.GetBasePath(Environment.GetEnvironmentVariable("CENTRAL_APPLICATION_SETTINGS")))
      .AddJsonFile("mssettings.json")
      .Build();
      var builder = new DbContextOptionsBuilder&lt;ManagementStudioDbContext&gt;();
      builder.UseSqlServer(configuration["DatabaseConfiguration:ConnectionString"]);
      return new ManagementStudioDbContext(builder.Options);
  }
  </code></pre>
  
  <p>This is how I declared my DbContext:</p>
  
  <pre><code>public ManagementStudioDbContext(DbContextOptions&lt;ManagementStudioDbContext&gt; options) : base(options)
  {
  
  }
  </code></pre>
  
  <p>However, this is a problem when I want to use the using() block as I will need to pass a parameter of type options to it. What can I pass so that I can use this using() block?</p>