The term 'add-migration' is not recognized

2019-07-14 05:21发布

So randomly from one day to the next my migrations stopped working. I do add-migration and it says its not being recognized. I'm using PM since this is a asp.net mvc and was working the day before.

add-migration : The term 'add-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.

enter image description here

7条回答
ら.Afraid
2楼-- · 2019-07-14 06:05

Even simpler for me, just re-starting VS2017 fixed this. Not had it until I got VS2017 professional, so this may be an issue for others in the latest version.

查看更多
对你真心纯属浪费
3楼-- · 2019-07-14 06:06
  1. In the nuget console, check if you have a right project selected as default.
  2. Set this project as a startup project
查看更多
我想做一个坏孩纸
4楼-- · 2019-07-14 06:09

This isn't exactly the issue the OP is having, but for dotnet core at least, this can also be caused by not having the Microsoft.EntityFrameworkCore.Tools nuget package installed, which is used for the package manager commands in Visual Studio and command line.

查看更多
我想做一个坏孩纸
5楼-- · 2019-07-14 06:17

I had this same problem, and simply closing the Package Manager Console, then restarting Visual Studio fixed it.

查看更多
神经病院院长
6楼-- · 2019-07-14 06:18

I suspect that your default project needs to be set, as Kirk Larkin mentioned in the comments. Click the drop down list on default project and set it to which ever project you have entity framework installed on.

enter image description here

Also this link might help if your default project drop down list won't populate NuGet Package Manager Console Default Project dropdown is empty

Hope this helps! If not let me know and I'll remove the answer(I had to use an answer because I can't comment under 50 rep) Cheers!

查看更多
神经病院院长
7楼-- · 2019-07-14 06:19

I reinstalled Nuget package manager and it worked for me. Fist I uninstalled the previous version, 2.0.x, then installed version 2.8.x

查看更多
登录 后发表回答