title: Code first migrations database error
body: <p>I used <a href="https://app.pluralsight.com/player?course=aspdotnet-mvc5-fundamentals&amp;author=scott-allen&amp;name=aspdotnet-mvc5-fundamentals-m6-ef6&amp;clip=3&amp;mode=live" rel="nofollow noreferrer">this</a> pluralsight video on MVC code first migrations to keep my default MVC IdentityDb context and create another context for custom tables.  Since then I get an error trying to connect connecting to the database online:</p>
  
  <blockquote>
    <p>CREATE DATABASE permission denied in database 'master'.
    .........</p>
  </blockquote>
  
  <p>It works locally. My connection string are correct and my context classes point to the right connection string name:</p>
  
  <pre><code>public class IdentityDb : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public IdentityDb()
          : base("DefaultConnection", throwIfV1Schema: false)
      {
      }
  
      public static IdentityDb Create()
      {
          return new IdentityDb();
      }
  }
  
  public class CustomDb : DbContext
  {
      public CustomDb() : base("DefaultConnection") { }
      public DbSet&lt;Inquiry&gt; Inquiry { get; set; }
      public DbSet&lt;Product&gt; Product { get; set; }
  }
  </code></pre>
  
  <p>Connection string:</p>
  
  <pre><code>&lt;add name="DefaultConnection" connectionString="server=***.db.1and1.com; initial catalog=***;uid=***;pwd=***"  providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>I've read that the connection string name should be the same as the context class name but since I have two contexts I need a common name (DefaultConnection) which I've specified in the contexts.</p>
  
  <p>It works connecting to my local database but not when its online so I did wonder if this would relate to the migration history table being up to date online and EF 6 trying to update the database but the entries in the migrations table match.</p>
  
  <p>Any help appreciated.</p>
  
  <p><strong>* UPDATE *</strong></p>
  
  <p>I tried resetting the EF migrations with <a href="https://weblog.west-wind.com/posts/2016/Jan/13/Resetting-Entity-Framework-Migrations-to-a-clean-Slate" rel="nofollow noreferrer">this</a> guide thinking if the migrations where out of sync with the online DB it could result in EF trying to re-create the database causing this issue.  However the problem still persists!</p>
  
  <p>I have now added these lines to my context constructors respectively:</p>
  
  <pre><code>Database.SetInitializer&lt;IdentityDb&gt;(null);
  
  Database.SetInitializer&lt;CustomDb&gt;(null);
  </code></pre>
  
  <p>This has stopped the error but kind of defeated the purpose of EF because I now have to remove it when creating migrations and manually script the changes to the online DB, then put it back in for the site to work online.</p>