The term 'Enable-Migrations' is not recogn

2019-06-19 07:45发布

问题:

When I enter this command: 'Enable-Migrations' in Package Manager Console I get this error:

"The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a p ath was included, verify that the path is correct and try again. At line:1 char:18 + Enable-Migrations <<<< + CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException"

I am using VS2010 with EF 4.0 and I was just doing really simple test project for deploying web site with windows azure,but for some reason I can not enable migrations.

Anyone has any idea? Thanks

回答1:

Try to restart Visual Studio. It helped in my case.



回答2:

First thing you need VS2010 Professional SP1.

After that please reinstall application package with commmand Install-Package EntityFramework -IncludePrerelease and it should solve your problem.



回答3:

If you have the latest EntityFramework and the 'Enable-Migrations' command is still showing the error reinstall/upgrade NuGet, see documentation: http://docs.nuget.org/docs/start-here/installing-nuget



回答4:

Make sure you have a solution opened. I got this error because I tried to run it without any solution opened. When I opened a solution it worked fine



回答5:

I was working on existing code-base which already had Entity Framework 5.x was installed. Some of the solutions suggested to upgrade to latest version and run but, installing the newest version remove System.Data.Entity. Adding the reference again caused errors in my old code which was using deprecated APIs.

The solution is run as administrator if you've already installed the framework in your solution



回答6:

I had this exact problem and was using an old version of NuGet, what worked for me was updating NuGet via the extensions interface.



回答7:

"Install-Package EntityFramework" will work just as well