简体   繁体   中英

The term 'add-migration' is not recognized as the name of a cmdlet

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.

在此处输入图片说明

这并不是 OP 遇到的问题,但至少对于 dotnet 核心,这也可能是由于未安装Microsoft.EntityFrameworkCore.Tools nuget 包引起的,该包用于 Visual Studio 中的包管理器命令和命令线。

What I had to do...

1) Tools -> Nuget Package Manger -> Package Manager Settings

2) General Tab

3) Clear All NuGet Cache(s)

4) Restart Visual Studio

我遇到了同样的问题,只需关闭包管理器控制台,然后重新启动 Visual Studio 即可修复它。

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.

在此处输入图片说明

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!

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.

  1. In the nuget console, check if you have a right project selected as default.
  2. Set this project as a startup project

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

Ok, also we get the same error when "add-migration", i try one solution which is update Package Manager by using follow step

  1. In Visual Studio, from the "Tools" menu choose the "Extensions and Updates" option.
  2. From the dialog that appears, expand the "Updates" node from the tree at the left side.
  3. Select the "Visual Studio Gallery" option from the tree.
  4. Finally, look for the Package Manager update in the list of updates at the right side of the dialog and click the "Update" button beside it.

it is approx 5 - 10 MB update, after update complete try Get-Help Add-Migration

If you are facing this issue in Visual Studio for Mac then simply re-install Nuget Package Manager Console extension. It will solve your problem

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM