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

前端 未结 26 3006
渐次进展
渐次进展 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: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 */

提交回复
热议问题