title: Entity Framework Automated Migration multiple context
body: <p>I have two databases. When I make a change to one of my dbcontext (adding a new DbSet) it should automatically apply the changes to the correct databases when runnnig my webapplication. So the new table should be added. Therefore I have added two configuration classes. One for each database/context.</p>
  
  <p>However using the initializers like below the changes are always applied to the second context/database. Because this is the latest initializer configured.</p>
  
  <pre><code>Database.SetInitializer(new MigrateDatabaseToLatestVersion&lt;DomainReadModelContext, DomainConfiguration&gt;());
  Database.SetInitializer(new MigrateDatabaseToLatestVersion&lt;WebsiteReadModelContext, WebsiteConfiguration&gt;());
  </code></pre>
  
  <p>I also tried it in the web.config</p>
  
  <pre><code>&lt;contexts&gt;
    &lt;context type="Domain.ReadModels.DomainReadModelContext, Domain.ReadModels"&gt;
      &lt;databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[Domain.ReadModels.DomainReadModelContext, Domain.ReadModels], [Website.Migrations.Domain.DomainConfiguration, Website-WebAppMainModule, Version=1.0.0.0, Culture=neutral]], EntityFramework" /&gt;
    &lt;/context&gt;
    &lt;context type="Website.ReadModels.WebsiteReadModelContext, Website.ReadModels"&gt;
      &lt;databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[Website.ReadModels.WebsiteReadModelContext, Website.ReadModels], [Website.Migrations.Website.WebsiteConfiguration, Website-WebAppMainModule, Version=1.0.0.0, Culture=neutral]], EntityFramework" /&gt;
    &lt;/context&gt;
  &lt;/contexts
  </code></pre>
  
  <p>When applying the changes via the package manager it works as it should be. The table gets added to my domaincontext database.</p>
  
  <pre><code>Update-Database -config DomainConfiguration
  </code></pre>
  
  <p>Is this because this isn't supported or am I doing it wrong? Now it seems to work only for the latest initializer registered.</p>
  
  <p>For the update I have scaffolded a Migration using the Add-Migration command in the package manager.</p>
  
  <pre><code>Add-Migration AddUniquePersonReadModelMigration -config DomainConfiguration
  </code></pre>
  
  <p>This generated following class for me.</p>
  
  <pre><code>public partial class AddUniquePersonReadModelMigration : DbMigration
  {
      public override void Up()
      {
          CreateTable(
              "UniquePersonReadModels",
              c =&gt; new
                  {
                      Id = c.Guid(nullable: false, identity: true),
                      PersonId = c.Guid(nullable: false),
                      DisplayName = c.String(maxLength: 128),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .Index(p =&gt; p.PersonId)
              .Index(p =&gt; p.DisplayName, true);
      }
  
      public override void Down()
      {
          DropIndex("UniquePersonReadModels", new[] { "PersonId" });
          DropIndex("UniquePersonReadModels", new[] { "DisplayName" });
          DropTable("UniquePersonReadModels");
      }
  }
  </code></pre>
  
  <p>So my question is does entity framework support the migrations for multiple contexts using initializers? If not, it would be a nice feature when the migrations can be handled for multiple contexts.</p>