February 2019 - Digital Tool Factory blog February 2019 - Digital Tool Factory blog

The Digital Tool Factory Blog

How to fix problems with entity framework migrations

  1. First – backup the __MigrationHistory table in the database
  2. Get rid of old migration files
  3. add-migration using the usual syntax, but with nothing modified
  4. Remove all of the “Create Table”, etc – the migration should look like
  5. public partial class domorenow : DbMigration
    {
    public override void Up()
    {

    <code>    }
    
        public override void Down()
        {
    
        }
    }</code>
  6. from there do the update-database -script to generate a sql file
  7. then just update-database -verbose
  8. All Fixed

14
Feb 19


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.