可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am using EF5 beta1 and while I was able to run the "Update-Database" before. Now that I shut down Visual Studio, I cannot get it to run. I get the following error:
The term 'Update-Database' 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:16
+ Update-Database <<<< -verbose
+ CategoryInfo : ObjectNotFound: (Update-Database:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have tried to re-install EF5b1 and while was successful (already installed), the 'Update-Database' still does not work.
Can anyone help???
回答1:
I've been having this problem a number of times lately. I found the solution that worked was to close the Package Manager Console, close Visual Studio and then reopen them. Rebooting also worked most of the time, but not always.
回答2:
If you use Entity Framework:
Error Message:
"Error Message (from the Update-Database command in the PMC):
The term 'Update-Database' 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."
Solution:
"Exit Visual Studio. Reopen project and try again."
For more information please visit: Advanced Entity Framework 6 Scenarios for an MVC 5 Web Application (12 of 12)
Hope this helps...
回答3:
Sometimes when I load VS, I see this in my package manager console:
Value cannot be null.
Parameter name: path1
I have no idea what causes that yet but it seems that something goes wrong during the start-up of the Powershell console which interrupts the registering of specific modules, such as the EF powershell extensions. You can just manually load it however:
Import-Module .\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1
Make sure you replace 6.1.1 with whatever your current version of Entity Framework is.
回答4:
Reinstalling the nuget package fixed this issue for me
ie, execute
Install-Package EntityFramework -Version 5.0.0
in the package manager
回答5:
you will get this error when the EF tools are not installed properly.
try the below command in Nuget package manager
//Uninstalls and install the same Version of EF
Update-Package "EntityFramework" -reinstall
If you still face the same issue.
create a new Web Project and run the below command in nuget.
(Note : no need to create the new Project in the same solution or
same location.)
// This will update EF to latest version(including the tools)
// if you want to use specific version , use the -version
flag.
Update-Package "EntityFramework"
Once this is done, chcek your original project and you can delete the newly created project.
回答6:
Just restart Visual Studio, it'll solve the problem. Works for me.
回答7:
I had this same problem, and the origin of it was on my path name, I had on my path a directory name with straight brackets, like this: C:\[PROJ]\TestApp
.
When I removed the brackets, to C:\PROJ\TestApp
, it started to work just fine...
回答8:
Just ReOpen visual studio is work for me
回答9:
For me the problem was the Nuget version.
- uninstall Nuget Package Manager.
- restart Visual Studio.
- installed new version of Nuget Package Manager.
- then re-start Visual Studio again.
回答10:
This problem seems to happen when you open the project directly from File Explorer. Try starting VS first and then opening the project - worked for me. I'm guessing this is about access to paths.
回答11:
In my case, I did the following:
- restored missing NuGet packages by clicking "Restore" button on top of Package Manager Console
- restarted Visual Studio
- run "update-databse"
回答12:
Restoring NuGet package didn'y help me. So I had to reinstall package manager - https://visualstudiogallery.msdn.microsoft.com/4ec1526c-4a8c-4a84-b702-b21a8f5293ca
May be it helps someone
回答13:
If the other answers don't work (VS 2017): clear the NuGet cache, restart VS, then restore the packages.
回答14:
I found that it was due to a corrupt package. I had installed Automapper when it was already installed. It was only clear that this package was corrupt when I tried to install another package.
Removing the corrupt package solved this issue for me.
You can then reinstall automapper. The issue was with version 5.4, I am now happily on 6.0.
回答15:
For me it turns out EntityFramework core was not installed on my project (because i started with blank project). So installing EntityFramework package resolved the problem. Sometimes if EntityFramework installation failed then try to install individual packages one by one
E.g.
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.SqlServer.Design
Microsoft.EntityFrameworkCore.Tools
回答16:
I solved by updateing Package Manager Console.
I was not getting Update-Database in Package Manager Console. Then i restart several time. Also restart Windows.
Then I download new one from nuget and then it was solved.
回答17:
I had this problem in Visual Studio 2015 and resolved it by updating the version of Nuget.
Tools -> Extensions and Updates -> Updates -> Visual Studio Gallery
回答18:
Simple fix for me was to make sure there was a dash between update and database, like this: update-database
and use lowercase. It may be coincidental, but when I did this in Packet Manager Console, the database actually updated and I got the done message rather than the not recognized as the name of a cmdlet, function, script file
error.
回答19:
I solved with uninstall and reinstall of "Microsoft.EntityFrameworkCore" and "Microsoft.EntityFrameworkCore.Tools"
回答20:
For me the problem was the Nuget version.
I removed and re-installed Nuget then re-started Visual Studio and then all started working.