在 .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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章