when the migrations database is changed in the DbContext and application runs before migrations are enabled, initial Update-Database fails<br /><br />Repro steps:<br />Create sample app, edit BlogContext.cs overriding OnModelCreate (see below)<br />run application<br />PM> Enable-Migrations<br />PM> Add-Migration m0<br />PM> Update-Database <br />error: There is already an object named 'Posts' in the database.<br /><br />public class BlogContext : DbContext {<br /> protected override void OnModelCreating(DbModelBuilder modelBuilder)<br /> {<br /> modelBuilder.HasDefaultSchema("__NewMigrationHistory");<br /><br /> }<br /><br /> public DbSet<Post> Posts { get; set; }<br /> public DbSet<Comment> Comments { get; set; }<br /> }<br /><br />
↧