title: Automatically Create Database in Entity Framework 6 with Automatic Migrations Disabled
body: <p>I would like to be able to automatically create a new database, if it does not exist, using code-first EF6 but with automatic migrations disabled.</p>
  
  <p>If i recall correctly, before automatic migrations existed in Entity Framework, this worked just fine.  However, in EF6, I receive the following exception:</p>
  
  <blockquote>
    <p><em>An exception of type 'System.Data.Entity.Migrations.Infrastructure.AutomaticMigrationsDisabledException'
    occurred in EntityFramework.dll but was not handled in user code</em></p>
    
    <p><em>Additional information: Unable to update database to match the current model because there are pending changes and automatic
    migration is disabled. Either write the pending model changes to a
    code-based migration or enable automatic migration. Set
    DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable
    automatic migration.</em></p>
  </blockquote>
  
  <p>To verify that this exception was not caused by a external factor in my production project, I created a new test project.  However, I get the same exception.</p>
  
  <p>For my database context, I have:</p>
  
  <pre><code>public class MyContext : DbContext
  {
      public DbSet&lt;Entity&gt; Entities { get; set; }
  
      public MyContext()
      {
          Database.SetInitializer(new CreateDatabaseIfNotExists&lt;MyContext&gt;());
      }
  }
  </code></pre>
  
  <p>Then I added a database migrations configuration file to disable automatic migrations:</p>
  
  <pre><code>public class DatabaseConfiguration : DbMigrationsConfiguration&lt;MyContext&gt;
  {
      public DatabaseConfiguration()
      {
          this.AutomaticMigrationsEnabled = false;
      }
  }
  </code></pre>
  
  <p>I just need to be able to create a new database if one does not exist (so I can quickly delete and recreate a new database for rapid development on my dev machine).  However, I don't want to enable automatic migrations because we do migrations in production with 3rd party tools, and EF6 complains if the schema has changed when automatic migrations is enabled.</p>
  
  <p>Any insight or alternative options that address these needs would be greatly appreciated. Thanks!</p>