How to unapply a migration in ASP.NET Core with EF Core

前端 未结 16 2153
余生分开走
余生分开走 2020-12-07 08:10

When I run PM> Remove-Migration -context BloggingContext in VS2015 with an ASP.NET Core project using EF Core I get the following error:

Syst         


        
相关标签:
16条回答
  • 2020-12-07 08:57

    Simply you can target a Migration by value

     Update-Database -Migration:0
    

    Then go ahead and remove it

     Remove-Migration
    
    0 讨论(0)
  • 2020-12-07 08:57

    In Package Manager Console:

    Update-Database Your_Migration_You_Want_To_Revert_To

    More options and explanation on how to revert migrations can be seen here

    0 讨论(0)
  • 2020-12-07 09:02

    You can still use the Update-Database command.

    Update-Database -Migration <migration name> -Context <context name>
    

    However, judging by the name of your migration i'm assuming it's the first migration so that command may not work. You should be able to delete the entry from the __MigrationHistory table in your database and then run the Remove-Migration command again. You could also delete the migration file and just start again.

    0 讨论(0)
  • 2020-12-07 09:03

    1.find table "dbo._EFMigrationsHistory", then delete the migration record that you want to remove. 2. run "remove-migration" in PM(Package Manager Console). Works for me.

    0 讨论(0)
提交回复
热议问题