The term 'Update-Database' is not recognized as the name of a cmdlet
Solution 1
The solution is to close the Package Manager Console, close Visual Studio and then reopen them.
Rebooting also worked most of the time, but not always.
Solution 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)
Solution 3
For anyone who is using .Net Core and EntityFrameworkCore:
You will need to install Microsoft.EntityFrameworkCore.Tools
package to resolve this issue.
Read more here: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
Solution 4
Reinstalling the nuget package fixed this issue for me
ie, execute
Install-Package EntityFramework -Version 5.0.0
in the package manager
Solution 5
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.
user1265146
Updated on July 08, 2022Comments
-
user1265146 almost 2 years
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???
-
RickAndMSFT almost 11 yearsUsually you just need to exit restart VS. See my comments in the original question.
-
RickAndMSFT almost 11 yearsUsually you just need to exit restart VS. See my comments in the original question. On rare occasions you might need to exit/restart VS twice.
-
stack247 almost 10 yearsThis works for me. The project I worked on used EF and I automatically assume the package was installed. Turned out, it wasn't. The developer just referenced directly to EF dll. EntityFramework package must be installed in the project for Update-Database cmd to work.
-
Shubh almost 9 yearsJust faced the problem and restarted Visual Studio and things were working again. Thanks.
-
parliament almost 9 yearsThank you! Only solution that worked for me. However, for anyone using EF 6.1.3 with VS 2015 there is a bug in EntityFramework.psm1 and there's a patch available here stackoverflow.com/a/30062684/1267778.
-
Nelson Miranda over 8 yearsThis answer seems unlikely to help however it it saved my day. Thanks,
-
Oak over 8 yearsThis was the case for me but I just needed to update nuget in extensions and update
-
Matt Borja over 8 yearsWrestling with FK's today using Fluent API, etc. and somehow EntityFramework keeps getting dropped. What actually worked for me along these lines was to do yet another
Update-Package -Reinstall EntityFramework
. -
Rizan Zaky over 7 yearsthis worked for me, uninstalled nuget package manager, re installed nuget package manager, restarted visual studio, uninstalled EntityFramework, re installed EntityFramework
-
sohaib javed over 7 yearsVS developer team should give Refresh VS button for such issues :)
-
Murat Yıldız over 7 years@sohaibjaved For some issues, restarting VS would not be enough and some directory cleaning is needed as indicated on Visual Studio 2015 extremely slow. FYI...
-
EKanadily over 7 yearsi lost count of how many things are solved by restarting visual studio
-
ProfK almost 7 yearsThank you, for an effective, if not crappy solution. It seems to be all that works out of a million things I've tried.
-
ProfK almost 7 years@RickAndMSFT This is a lot closer to a better solution that "just" restarting VS.
-
Khateeb321 over 6 yearsYes, of course. This is the solution. Legit solution. Thank you Microsoft!
-
User5590 about 6 years@Antonio Even I had the same problem and your solution worked for me as well.
-
Kirk Woll about 5 yearsIf you're using EF Core, this is the correct answer. Or at least, the problem for me was that
Microsoft.EntityFrameworkCore.Tools
was not installed. -
RustemMazitov almost 5 yearsfor me reinstall and reboot. just reinstall dont work, and just reboot dont work either)
-
Niklas almost 5 yearsafter restarting a few times and not getting it resolved, this helped solve my issue!
-
Prince Tegaton over 4 yearsIt's really funny how restarting my PC works for this issue
-
HaBo over 4 yearsI installed "Microsoft.EntityFrameworkCore.Tools" Version="3.1.0" on my data projects and "Microsoft.EntityFrameworkCore.Design" Version="3.1.0" on my main web project, that resolved issue for me.
-
Janneman96 over 4 yearsYes!! Thanks =) I only had EntityFramwork, EF.Design, EF.SqlServer and EF.SqlServer.Design installed.
-
Grayson over 4 yearsThat was it for me Habo. Thanks. You should add that as an answer instead of comment
-
YannickIngenierie over 2 yearsNeed to do it 2 times.. but work