The term “Add-Migration” is not recognized

后端 未结 18 2157
情深已故
情深已故 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:31

    ​What I had to do...

    1) Tools -> Nuget Package Manger -> Package Manager Settings

    2) General Tab

    3) Clear All NuGet Cache(s)

    4) Restart Visual Studio

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

    same issue...resolved by dong the following

    1.) close pm manager 2.) close Visual Studio 3.) Open Visual Studio 4.) Open pm manager

    seems the trick is to close PM Manager before closing VS

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

    In my case I added dependency via Nuget:

    Microsoft.EntityFrameworkCore.Tools

    And then run via Package Manager Console:

    add-migration Initial -Context "ContextName" -StartupProject "EntryProject.Name" -Project "MigrationProject.Name"
    
    0 讨论(0)
  • 2020-12-08 00:35

    Just try init Microsoft.EntityFrameworkCore.Tools. In PM execute

    C:\Users\<username>\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview2-final\tools\init.ps1.
    

    It helped me with the same problem. A version of the tools might be different. It`s depended of what you use in your project.

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

    These are the steps I followed and it solved the problem

    1)Upgraded my Power shell from version 2 to 3

    2)Closed the PM Console

    3)Restarted Visual Studio

    4)Ran the below command in PM Console dotnet restore

    5)Add-Migration InitialMigration

    It worked !!!

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

    Try the following steps:

    1) Open project.json file and Remove all Microsoft.EntityFrameworkCore.Tools references from dependencies and tools sections.

    2) Close Package Manager Console (PMC) and restart Visual Studio

    3) Add under dependencies section:

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

    4) Add under tools section

    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
    

    5) Restart again Visual Studio 2015

    6) Open the PMC and type

    Add-Migration $Your_First_Migration_Name$
    

    This happen because the PMC recognize the tools when Visual Studio is starting.

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