How do you downgrade a Entity Framework 5 migration in Visual Studio 2012?

前端 未结 2 1063
忘掉有多难
忘掉有多难 2021-02-02 08:43

I\'ve noticed that when I create a code first database migration using add-migration it generates a Down() method as well as an Up() metho

2条回答
  •  遇见更好的自我
    2021-02-02 09:26

    After almost giving up with researching on Google I managed to find this quote from here:

    • http://msdn.microsoft.com/en-gb/data/jj591621.aspx#specific

    Which Specifies:

    Let’s say we want to migrate our database to the state it was in after running our AddBlogUrl migration. We can use the –TargetMigration switch to downgrade to this migration.

    Run the Update-Database –TargetMigration: AddBlogUrl command in Package Manager Console. This command will run the Down script for our AddBlogAbstract and AddPostClass migrations.

    If you want to roll all the way back to an empty database then you can use the Update-Database –TargetMigration: $InitialDatabase command.

提交回复
热议问题