Entity Framework: Add-Migration fails with Unable to update database

后端 未结 4 865
别那么骄傲
别那么骄傲 2021-02-03 11:24

I have been using Entity Framework (5.0) for a while now in a project (ASP.NET MVC in VS2012 Express). Right now, though, I am no longer able to add migrations.

         


        
4条回答
  •  情书的邮戳
    2021-02-03 11:45

    You can reset the entity framework to solve your problem [But keep it mind it will bring the Migration to the default state]

    Note: To take a backup before performing the following

    You need to delete the present state:

    • Delete the migrations folder in your project
    • Delete the __MigrationHistory table in your database (may be under system tables)

    You will find the __MigrationHistory table in your database [Under App_Data Folder]

    Then run the following command in the Package Manager Console:

    Enable-Migrations -EnableAutomaticMigrations -Force
    

    Use with or without -EnableAutomaticMigrations

    And finally, you can run:

    Add-Migration Initial
    

    This may also help you

提交回复
热议问题