The term 'Update-Database' is not recogniz

2019-01-21 10:18发布

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???

20条回答
该账号已被封号
2楼-- · 2019-01-21 10:24

If the other answers don't work (VS 2017): clear the NuGet cache, restart VS, then restore the packages.

查看更多
Emotional °昔
3楼-- · 2019-01-21 10:24

I solved with uninstall and reinstall of "Microsoft.EntityFrameworkCore" and "Microsoft.EntityFrameworkCore.Tools"

查看更多
Anthone
4楼-- · 2019-01-21 10:26

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.

查看更多
神经病院院长
5楼-- · 2019-01-21 10:26

Just ReOpen visual studio is work for me

查看更多
Luminary・发光体
6楼-- · 2019-01-21 10:26

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.

查看更多
forever°为你锁心
7楼-- · 2019-01-21 10:29

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.

查看更多
登录 后发表回答