title: EF Core Migrations with multiple DbContexts on single database
body: <p>I have an issue attempting to use Migrations in a ASP.NET Core solution using EF Core where there are multiple <code>DbContext</code> that share the same SQL database.</p>
  
  <p>In my application startup method I'm getting a reference to each context and calling the <code>context.Database.Migrate()</code> method. However as both of these contexts are pointing to the same underlying database I'm getting the error:</p>
  
  <blockquote>
    <p>There is already an object named '__EFMigrationsHistory' in the database.</p>
  </blockquote>
  
  <p>Here's a MCVE:</p>
  
  <pre><code>class DbContextA : DbContext {}
  class DbContextB : DbContext {}
  
  static void Main(string[] args)
  {
    var contextA = GetContextFromDIContainer&lt;DbContextA&gt;();
    var contextB = GetContextFromDIContainer&lt;DbContextB&gt;();
  
    contextA.Database.Migrate();
    contextB.Database.Migrate();
  }
  
  void ConfigureServices(IServiceCollection services)
  {
    services.AddDbContext&lt;DbContextA&gt;(opt =&gt;
    {
      opt.UseSqlServer("connectionstring");
    });
  
    services.AddDbContext&lt;DbContextB&gt;(opt =&gt;
    {
      opt.UseSqlServer("connectionstring");
    });
  }
  </code></pre>
  
  <p>Note that each <code>DbContext</code> exists in a separate assembly in which the Migrations are configured.</p>
  
  <p>I am able to manually execute the respective migrations with the <code>Update-Database</code> CLI tool but it doesn't seem to work as part of my app startup code.</p>
  
  <p>Is there a way to execute migrations on both contexts at runtime and bypass the <code>__EFMigrationsHistory</code> table creation if already exists?</p>