title: EF Core - Connection string cannot be null
body: <p>I am using <code>ASP.Net Core 2.1</code> with <code>EF Core 2.1</code></p>
  
  <p>While running any Migration from PMC, I am getting the below error </p>
  
  <blockquote>
    <p>Value cannot be null. Parameter name: connectionString</p>
  </blockquote>
  
  <p>This is how my Context class looks like</p>
  
  <pre><code>public class MyAppContextFactory : IDesignTimeDbContextFactory&lt;MyAppContext&gt;
  {
      private readonly string _dbConnection;
  
      public MyAppContextFactory()
      {
  
      }
      public MyAppContextFactory(string dbConnection)
          : this()
      {
          _dbConnection = dbConnection;
  
      }
  
      public MyAppContext CreateDbContext(string[] args)
      {
          var optionsBuilder = new DbContextOptionsBuilder&lt;MyAppContext&gt;();
          optionsBuilder.UseSqlServer(_dbConnection, opts =&gt; opts.CommandTimeout((int)TimeSpan.FromMinutes(15).TotalSeconds));
          return new MyAppContext(optionsBuilder.Options);
      }
  
  
  }
  </code></pre>
  
  <p>My Connection string is present in API layer in appsettings.json &amp; as good practice I should not add any reference to EF in API/UI layer.</p>
  
  <p>How do I set the connection string as per environment in such layered architecture?</p>
  
  <p>Thanks.</p>