The term “Add-Migration” is not recognized

后端 未结 18 2156
情深已故
情深已故 2020-12-07 23:51

I\'m using this MSDN Tutorial to run in VS2015 the command PM> Add-Migration MyFirstMigration -context BloggingContext that ran yesterday successfully but to

相关标签:
18条回答
  • 2020-12-08 00:20

    I had this problem and none of the previous solutions helped me. My problem was actually due to an outdated version of powershell on my Windows 7 machine - once I updated to powershell 5 it started working.

    0 讨论(0)
  • 2020-12-08 00:23

    I just had this problem too. I closed and opened VS2015 and it "fixed" the issue...

    0 讨论(0)
  • 2020-12-08 00:23

    I ran into the same issue. Most of my projects had the same thing in tools.

    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
    }
    

    This worked fine on all but one project. I changed the entry in tools to

    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": {
        "version": "1.0.0-preview2-final",
        "type": "build"
      }
    }
    

    And then ran dotnet restore. After the restore completed, Add-Migration worked normally.

    0 讨论(0)
  • 2020-12-08 00:25

    It's so simple.

    Just install Microsoft.EntityFrameworkCore.Tools package from nuget:

    Install-Package Microsoft.EntityFrameworkCore.Tools -Version 3.1.5

    You can also use this link to install the latest version: Nuget package link

    .NET CLI command:

    dotnet add package Microsoft.EntityFrameworkCore.Tools
    
    0 讨论(0)
  • 2020-12-08 00:25

    I tried doing all the above and no luck. I downloaded the latest .net core 2.0 package and ran the commands again and it worked.

    0 讨论(0)
  • 2020-12-08 00:26

    Go to package manager console(in visual studio) and execute below command

    C:\Users\<YOUR_USER>\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\<YOUR_INSTALLED_VERSION>\tools\init.ps1

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