Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a new empty EF Migration?

Ok, so I'm relying completely on my migrations and seed code to maintain all database structure and initial data. Because of that, I'm facing a situation where all the changes I'm doing at this version are made directly on the database (Stored Procs and Updates) and nothing has changed on the C# code itself.

The question is: Since I want to do those DataBase specific changes using a new migration (and an "add-migration" will do nothing - cause the code hasn't change), how can I force a new empty code first migration to put my changes manually on it?

like image 397
Marcelo Myara Avatar asked Mar 05 '14 11:03

Marcelo Myara


1 Answers

In the package manager console issue the command

Add-Migration "My new empty migration"

This will generate this migration template

public partial class Mynewemptymigration : DbMigration
{
    public override void Up()
    {
    }

    public override void Down()
    {
    }
}

You can then create your own custom up and down migration steps. If you model is not up to date there will be migration code in the up and down. In that case you'll have to get your model up to date and then add a new empty migration.

like image 96
David Sopko Avatar answered Oct 07 '22 02:10

David Sopko