更新 .NET Core 工具

编程入门 行业动态 更新时间:2024-10-24 12:23:49
本文介绍了更新 .NET Core 工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I'm trying to use EntityFrameworkCore@3.1. In order to do this at this point I already have: - Installed Visual Studio 2019 Preview - Installed the .NET Core 3.1 Runtime - Installed the .NET Core 3.1 SDK

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

Now I still can't run the command dotnet ef migrations add xxx. It's saying that I have to update the dotnet tools. So I run the following command in an administrator 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')

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

Okay, not including the preview versions. So I try to specify the version explicitly:

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 aka.ms/failure-installing-tool

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

Now it's saying that a .NET Core 3.1 tool is not compatible with the .NET Core 3.1 runtime.

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

However, if I do a simple version check:

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(我的项目中安装了哪个工具版本).

I can see that the EntityFrameworkCore.Tools is still at version 3.0.0 instead of 3.1.0 (which tools version is installed in my project).

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

Am I still missing something or is this a bug?

推荐答案

感谢 @lars-haupt-hansen 指出错误,我 遵循跟踪到 PR 显示它已合并到aspnet:release/3.1".最新的 3.1 仍然是预览 (preview3) .您可以在此处找到并下载最新的 SDK.

Thanks to @lars-haupt-hansen for pointing me to the bug, I followed the trail to the PR which shows it was merged into "aspnet:release/3.1". The latest 3.1 is still a preview (preview3) [edit: it's out of preview]. You can find and download the latest SDK here.

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

To use it in Visual Studio projects, you have to

  • 从上面的链接安装 SDK;
  • 转到工具">选项">环境">预览功能"并启用使用 .NET Core SDK 的预览";(3.1 不再需要)
  • 重启 VS (3.1 不再需要)
  • 转到每个项目属性,然后您可以选择目标框架.NET Core 3.1
  • 然后要通过命令行安装 EF Core,请从项目目录运行 dotnet tool install --global dotnet-ef.

    Then to install EF Core via the command line, run dotnet tool install --global dotnet-ef from your project directory.

    更多推荐

    更新 .NET Core 工具

    本文发布于:2023-11-14 14:54:16,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1587619.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:工具   NET   Core

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!