【发布时间】:2021-04-04 02:19:33
【问题描述】:
我正在使用 Visual Studio for Mac 并拥有 .NET Core 2.1 项目。我在使用“Add-Migration”之类的迁移命令时遇到问题,即出现以下错误:
**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**
你知道这可能是什么原因吗?
【问题讨论】:
-
Add-Migration来自 EF 6,而不是来自 EF Core,因此它不起作用是完全有道理的。请阅读docs.microsoft.com/en-us/ef/core/cli/… -
你需要添加正确的nuget包。相信它的实体框架核心工具
-
@CamiloTerevinto 如果在 Visual Studio 中调用,则添加迁移在 EF Core 中是正确的。见docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/…
-
@ahmedGaber。您是从 Visual Studio 还是从命令行运行添加迁移?
-
感谢 Visual Studio 的 @Julian 回复,现在卸载并安装 Microsoft.EntityFrameworkCore.Tools 后正在工作
标签: asp.net-core entity-framework-core database-migration entity-framework-migrations visual-studio-mac