【问题标题】:Update .NET Core Tools更新 .NET Core 工具
【发布时间】:2020-02-21 05:55:42
【问题描述】:

我正在尝试使用 EntityFrameworkCore@3.1。为了做到这一点,我已经有了: - 安装 Visual Studio 2019 预览版 - 安装了 .NET Core 3.1 运行时 - 安装了 .NET Core 3.1 SDK

现在我仍然无法运行命令dotnet ef migrations add xxx。据说我必须更新 dotnet 工具。所以我在管理员 powershell 中运行以下命令:

PS C:\WINDOWS\system32> dotnet tool update --global dotnet-ef
Tool 'dotnet-ef' was reinstalled with the latest stable version (version '3.0.0')

好的,不包括预览版。所以我尝试明确指定版本:

PS C:\WINDOWS\system32> dotnet tool update --global dotnet-ef --version="3.1.0-preview1.19506.2"
error NU1202: Package dotnet-ef 3.1.0-preview1.19506.2 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any. Package dotnet-ef 3.1.0-preview1.19506.2 supports: netcoreapp3.1 (.NETCoreApp,Version=v3.1)
Tool 'dotnet-ef' failed to update due to the following:
The tool package could not be restored.
Tool 'dotnet-ef' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

现在说 .NET Core 3.1 工具与 .NET Core 3.1 运行时不兼容。

但是,如果我做一个简单的版本检查:

PS C:\WINDOWS\system32> dotnet --version
3.1.100-preview1-014459
PS C:\WINDOWS\system32> dotnet ef --version
Entity Framework Core .NET Command-line Tools
3.0.0

我可以看到 EntityFrameworkCore.Tools 仍然是 3.0.0 版本而不是 3.1.0(我的项目中安装了哪个工具版本)。

我还是遗漏了什么还是这是一个错误?

【问题讨论】:

  • 你安装了 16.4 preview 2 吗?
  • 我的版本是16.4.0 Preview 2.0
  • 我尝试在另一台笔记本电脑上安装新的 Windows,然后我立即选择了 .NET Core 3.1,没有其他 .NET Core 框架。现在,当我运行dotnet --version 时,我也得到3.1.100-preview1-014459dotnet ef --version 也给了我3.1.0。但是现在 dotnet ef 抱怨我使用 .NETCore3.1 并告诉它只与 .NETCore3.1 兼容。可能是一个错误。
  • 可能是。报告给微软

标签: visual-studio-2019 preview dotnet-tool


【解决方案1】:

感谢@lars-haupt-hansen 指出错误,我将followed trailPR 表明它已合并到“aspnet:release/3.1”中。 最新的 3.1 仍然是 preview (preview3) [编辑:它不在预览中]。您可以找到并下载最新的 SDK here

要在 Visual Studio 项目中使用它,您必须

  1. 从上述链接安装 SDK;
  2. 转到工具 > 选项 > 环境 > 预览功能并启用“使用 .NET Core SDK 的预览”; (不再需要 3.1)
  3. 重启 VS (3.1 不再需要)
  4. 进入各个项目属性,然后可以选择目标框架.NET Core 3.1

然后要通过命令行安装 EF Core,请从您的项目目录运行 dotnet tool install --global dotnet-ef

【讨论】:

    【解决方案2】:
    dotnet tool install -g dotnet-ef --version 3.0.0-preview4.19216.3
    
    dotnet tool install --global dotnet-ef --version 3.0.0-preview8.19405.11
    

    【讨论】:

    • 我怀疑这能否解决问题,甚至根本无法解决问题。为了说服我,请解释这是如何工作的以及为什么它应该有所帮助。
    猜你喜欢
    • 2019-02-06
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 2019-06-01
    • 2021-05-21
    • 2020-04-11
    • 1970-01-01
    相关资源
    最近更新 更多