Ubuntu 19.10 中的 dotnet ef 迁移问题。点网SDK 3.1.1

dotnet ef migrations issue in Ubuntu 19.10. Dotnet sdk 3.1.1

我安装了 dotnet ef 工具,以便为正在使用命令处理的 dotnet 核心项目生成迁移。 dotnet tool install -g dotnet-ef。安装成功。为了我们 dotnet ef 我已经安装了下面的 nuget 包

  1. Microsoft.EntityFrameworkCore.SqlServer
  2. Microsoft.EntityFrameworkCore
  3. Microsoft.AspNetCore.Identity.EntityFrameworkCore
  4. Microsoft.EntityFrameworkCore.工具

当尝试使用命令 dotnet ef migrations add IdentityandCategory 生成迁移时,我得到以下输出。

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.1' was not found.
  - The following frameworks were found:
      2.1.14 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
      2.2.8 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
      3.1.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.1&arch=x64&rid=ubuntu.19.10-x64

我重新安装了dotnet 3.1.1,但问题依旧。 dotnet info 似乎检测到版本 当我 运行 donet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.1.100
 Commit:    cd82f021f4

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  19.10
 OS Platform: Linux
 RID:         ubuntu.19.10-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.100/

Host (useful for support):
  Version: 3.1.0
  Commit:  157910edee

.NET Core SDKs installed:
  2.1.802 [/usr/share/dotnet/sdk]
  2.2.402 [/usr/share/dotnet/sdk]
  3.1.100 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

我该如何解决这个问题?预先感谢您的帮助

我 运行 今天在 Azure Pipelines 上解决了这个问题。修复它的最简单方法是通过指定您需要的确切版本来显式安装 dotnet-ef

dotnet tool install --global dotnet-ef --version 3.1.0

我认为 .NET Core Runtime 版本和 dotnet-ef 版本必须同步。由于最近发布了一个将 .NET Core 运行时提升到 3.1.1 的安全补丁,因此存在不匹配,这就是它抱怨的原因。

也就是说,在时间允许的情况下将所有内容更新为 3.1.1 可能是明智的。