在 .NET Core 3 中找不到命令 dotnet ef - Command dotnet ef not found in .NET Core 3

问题:

I'm following the docs in order to create an initial migration.我正在关注文档以创建初始迁移。 When I execute dotnet , I get the help section, meaning that the PATH works properly.当我执行dotnet ,我得到了帮助部分,这意味着 PATH 工作正常。

Then I try to execute the command below from the docs in console window:然后我尝试从控制台窗口中的文档执行以下命令:

dotnet ef migrations add InitialCreate dotnet ef 迁移添加 InitialCreate

I get the following error:我收到以下错误:

Could not execute because the specified command or file was not found.无法执行,因为找不到指定的命令或文件。
Possible reasons for this include:可能的原因包括:

  • You misspelled a built-in dotnet command.您拼错了内置的 dotnet 命令。

  • You intended to execute a .NET Core program, but dotnet-ef does not exist.您打算执行 .NET Core 程序,但 dotnet-ef 不存在。

  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.您打算运行一个全局工具,但在 PATH 中找不到具有此名称的 dotnet 前缀的可执行文件。

  • I excluded the first item since I copied the command.自从我复制命令以来,我排除了第一项。

  • I excluded the second item because the package Microsoft.EntityFrameworkCore.SqlServer is installed.我排除了第二项,因为安装了Microsoft.EntityFrameworkCore.SqlServer包。

  • I excluded the third item because I get the help section when invoking dotnet .我排除了第三项,因为我在调用dotnet时得到了帮助部分。

I'm googling the issue but since the version is new, there's not much to go on and/or it's drowning in similar issues from earlier versions.我在谷歌上搜索这个问题,但由于版本是新的,所以没有什么可做的和/或它淹没在早期版本的类似问题中。

I tried to forcibly install Microsoft.EntityFrameworkCore just in case it needs to be explicitly added.我试图强行安装Microsoft.EntityFrameworkCore以防万一需要明确添加。 I ran into the error message telling me that the latest version to pick from is 2.2.6 and a downgrade is a no-go.我遇到了错误消息,告诉我要选择的最新版本是 2.2.6,不能降级。 I'm not sure how to install the version compatible with the SQL-package I have on my system already (and even less certain if that's right approach to kill this issue).我不确定如何安装与我系统上已经拥有的 SQL 包兼容的版本(甚至不确定这是否是解决此问题的正确方法)。

Detected package downgrade: Microsoft.EntityFrameworkCore from 3.0.0-preview6.19304.10 to 2.2.6.检测到包降级:Microsoft.EntityFrameworkCore 从 3.0.0-preview6.19304.10 到 2.2.6。 Reference the package directly from the project to select a different version.直接从项目中引用包以选择不同的版本。
Web ->网页 ->
Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview6.19304.10 -> Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview6.19304.10 ->
Microsoft.EntityFrameworkCore.Relational 3.0.0-preview6.19304.10 -> Microsoft.EntityFrameworkCore.Relational 3.0.0-preview6.19304.10 ->
Microsoft.EntityFrameworkCore (>= 3.0.0-preview6.19304.10) Microsoft.EntityFrameworkCore (>= 3.0.0-preview6.19304.10)
Web -> Microsoft.EntityFrameworkCore (>= 2.2.6) Web -> Microsoft.EntityFrameworkCore (>= 2.2.6)


解决方案:

参考一: https://stackoom.com/question/3rRhA
参考二: Command dotnet ef not found in .NET Core 3
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章