EF Core 工具版本更新 2.1.1

EF Core tools version update 2.1.1

如果我运行dotnet ef add testmigration

我收到此警告:The EF Core tools version '2.1.0-rtm-30799' is older than that of the runtime '2.1.1-rtm-30846'. Update the tools for the latest features and bug fixes.

所以我检查了我的 csproj 文件:

<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
</ItemGroup>

在我看来是正确的,版本 2.1.1。 所以我检查了文档,here

他们建议 csproj 中的工具条目需要有这个包:

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.1" />
</ItemGroup>

现在 dotnet restore 抱怨:

warning : The tool 'Microsoft.EntityFrameworkCore.Tools.DotNet' is now included in the .NET Core SDK. Information on resolving this warning is available at (https://aka.ms/dotnetclitools-in-box).

并且dotnet ef --version仍然列出旧的。

所以我接下来要做的就是完全删除 csproj 中的条目,现在 dotnet ef 仍然有效,但仍然给我旧版本。

所以我想我必须以某种方式更新 EF 的 dotnet 全局工具。但是 'dotnet tools list -g' 没有结果。

一切都很混乱。

旧版本是从哪里来的,我该如何摆脱它it/update?

好的。

事实证明,这是由于安装了第二个最新的 sdk (2.1.301),但在路径的某处 global.json 固定到版本 2.1.300。

我遇到了这个问题。我尝试按照其他人的建议删除 bin 文件夹并重建,但从未奏效。最后我把SDK更新到2.1.403,问题解决了。

当您在 包管理器控制台 上 select 不同的项目 而不是 Entity Framework 解决方案中的项目。

install-package Microsoft.EntityFrameworkCore.Tools -Version 2.1.8

为我做了