Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project

前端 未结 26 2960
渐次进展
渐次进展 2020-11-28 06:55

I tried to run the command \'Enable-Migrations\' in a new project and I got the message:

PM> Enable-Migrations
The term \'Enable-Migrations\' is not recog         


        
相关标签:
26条回答
  • 2020-11-28 07:19

    Enable-Migrations -EnableAutomaticMigrations

    0 讨论(0)
  • 2020-11-28 07:19

    In VS 2013, try to install the UPDATE 1(RC1) and the problem is resolved.

    0 讨论(0)
  • 2020-11-28 07:22

    I had the same issue and I tried most of the solution provided by other folks but it worked for me with below steps. I have VS 2017.

    Steps:

    Install-Package EntityFramework -IncludePrerelease
    

    then create a class as

    public class MyDBContext : DbContext { public MyDBContext() { } }
    

    and at the last execute

    Enable-Migrations -EnableAutomaticMigrations
    

    What didn't work for me:

    : Restarting VS.

    : only "Enable-Migrations" command, which is without -EnableAutomaticMigrations.

    : restoring or updating Nuget Package Manager.

    My original error in the beginning was

    /* The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.At line:1 char:1 + enable-migration + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (enable-migration:String) [], CommandNotFoundException */

    0 讨论(0)
  • 2020-11-28 07:22

    I just had the same problem in asp.net core VS2019

    This solved it:

    Install-Package Microsoft.EntityFrameworkCoreInstall-Package
    Install-Package Microsoft.EntityFrameworkCore.Tools
    

    Don't forget to set default project in Package Manager Console to your database project in case it differs.

    While executing the migrations the default project also seems to play a role. At a later step it helped to install this to my main startup project (not the EF database project):

    Install-Package Microsoft.EntityFrameworkCore.Design
    
    0 讨论(0)
  • 2020-11-28 07:23
    1. Install Entity framework to the current project using the below command: PM> Install-Package EntityFramework -IncludePrerelease

    2. Add a class "MyDBContext" in the Model folder as given below:

      public class MyDBContext : DbContext { public MyDBContext() { } }

    3. Now enable migrations for the current project with the below command: PM> enable-migrations

    0 讨论(0)
  • 2020-11-28 07:23

    Check the version of the Entity Framework.

    if it is 6.3, downgrade it to 6.2 and it should work just fine

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