Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 无法在使用visual studio for mac的.net core 2.1项目中使用添加迁移_Asp.net Core_Entity Framework Core_Database Migration_Entity Framework Migrations_Visual Studio Mac - Fatal编程技术网

Asp.net core 无法在使用visual studio for mac的.net core 2.1项目中使用添加迁移

Asp.net core 无法在使用visual studio for mac的.net core 2.1项目中使用添加迁移,asp.net-core,entity-framework-core,database-migration,entity-framework-migrations,visual-studio-mac,Asp.net Core,Entity Framework Core,Database Migration,Entity Framework Migrations,Visual Studio Mac,我正在使用Visual Studio for Mac,并拥有.NET Core 2.1项目。我在使用任何迁移命令(如“添加迁移”)时遇到一个问题,即发生以下错误: **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

我正在使用Visual Studio for Mac,并拥有.NET Core 2.1项目。我在使用任何迁移命令(如“添加迁移”)时遇到一个问题,即发生以下错误:

**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.
At line:1 char:1
 + Add-Migration DBUpdates -Context applicationdbcontext
 + ~~~~~~~~~~~~~
 + CategoryInfo         : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException
 + FullyQualifiedErrorId : CommandNotFoundException**

有任何线索表明这可能是什么原因吗?

此错误表示缺少一个包


从nuget安装软件包Microsoft.EntityFrameworkCore.Tools。然后重新打开visual studio。

您可能缺少nuget软件包,如果不是这样,请再次检查visual studio中的powershell界面是否指向正确的项目(您想要的是DbContext对象所在并已定义的项目)


添加迁移
来自EF 6,而不是EF Core,因此完全可以理解它不起作用。请阅读您需要添加正确的nuget软件包。相信它是实体框架的核心tools@CamiloTerevinto如果在VisualStudio中调用,则在EF Core中添加迁移是正确的。见@Ahmedgeaber。A您是从visual studio还是从命令行运行添加迁移?感谢您的响应@Julian from visual studio,在卸载并安装Microsoft.EntityFrameworkCore.Tools后立即运行安装,然后安装Microsoft.EntityFrameworkCore.Tools并重新启动visual studio解决此问题