Entity Framework Code Migrations - Stuck on Initial Migration

后端 未结 7 1060
面向向阳花
面向向阳花 2020-12-14 07:58

I have added EF 5 to my project via Nuget and enabled migrations with the \"Enable-Migrations\" command. I have then called \"Add-Migration\" to generate the base code for g

相关标签:
7条回答
  • 2020-12-14 08:57

    Trying to migrate an old db version to a new model, either the database didn't match the new model or i got errors like :

    Type is not resolved for member 'Npgsql.PostgresException,Npgsql, Version=3.2.2.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'

    Here's how it worked (using automatic migration) :

    1. Delete Migrations folder
    2. Execute enable-migrations
    3. Set this two properties to true in the newly created Configuration.cs

      public Configuration()
      {
          AutomaticMigrationsEnabled = true;
          AutomaticMigrationDataLossAllowed = true;
      }
      
    4. Execute Update-Database -Force

    Your database will be updated to latest scheme and ready.

    hope this helps.

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