Entity framework core 需要更新EF核心工具
当我在VS 2017 Package Manager控制台中使用dotnet ef工具时,我收到一条关于需要更新ef核心工具的警告消息:Entity framework core 需要更新EF核心工具,entity-framework-core,Entity Framework Core,当我在VS 2017 Package Manager控制台中使用dotnet ef工具时,我收到一条关于需要更新ef核心工具的警告消息: PM> dotnet ef migrations list -s ../RideMonitorSite The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the lat
PM> dotnet ef migrations list -s ../RideMonitorSite
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.2-rtm-30932'. Update the tools for the latest features and bug fixes.
20180831043252_Initial
但我的csproj文件有以下条目:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.2" />
</ItemGroup>
那么我该如何更新这些工具呢?顺便说一句,我在其他答案中看到,过期的global.json文件可能会导致此问题。但是我在解决方案中的任何地方都没有global.json文件。安装新的.NET Core SDK v2.1.401版本,然后再次检查>dotnet ef--version。我有同样的问题,在我的情况下,这是有效的。另外,您不需要添加Microsoft.EntityFrameworkCore.Tools.DotNet。我将此问题提交给了。事实证明,这是当前工具或nuget包中的一个错误,当您创建一个EF Core支持的AspNet Core站点时,这些工具或nuget包会被加载。它的目标是在未来的版本中修复 目前,解决办法只是忽略警告
另外还提供了另一种解决方法,包括调整csproj文件以明确定义AspNet核心元包的版本——在我写这篇文章时,它是2.1.3版本——但我无法让这种方法起作用;我仍然不断收到警告消息。我找不到如何具体更新包,但在包管理器控制台中,我运行了“更新包”。它运行并更新了项目中引用的所有包,包括EF核心工具。这可能不适合您,因为这可能会更新您不想要的包 我的解决方案是从microsoft安装工具dotnet ef。它使用相同的命令,但没有警告。更改是使用dotnet ef而不是dotnet ef 如果已经安装了dotnet ef,则使用
dotnet工具更新--global dotnet ef--version n.n.n
(n.n.n您要更新的版本)- 忽略这个问题
- 不要更新您的
- 在我的例子中,我继续使用“更新数据库-上下文MyElementContext”,现在一切正常
更新包Microsoft.EntityFrameworkCore.Tools按照本文档中的步骤帮助我解决了问题- 在Visual Studio中使用包管理器控制台构建数据库
- 打开Visual Studio并为C#创建新的控制台应用程序(.NET Core)
- 使用PackageManager控制台为EF Core添加MySQL NuGet包。例如,使用以下命令添加MySql.Data.EntityFrameworkCore v8.0.13包:
- 通过选择其中一个软件包安装以下NuGet软件包
管理器控制台或管理工具中解决方案的NuGet包
然后是NuGet Package Manager菜单:
Microsoft.EntityFrameworkCore.Design EF Core 1.1 only: Also add the MySql.Data.EntityFrameworkCore.Design package. Microsoft.EntityFrameworkCore.Tools version 1.1.6 (for EF Core 1.1) and Microsoft.EntityFrameworkCore.Tools version 2.0.3 (for EF Core 2.0) Note The .NET tools are included in the .NET Core 2.1 SDK and not required or supported for EF Core 2.1. If this is an upgrade, remove the reference to that package from the .csproj file (version 2.0.3 in this example) : <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
打开Package Manager Console,并在提示下输入以下命令,为Microsoft.EntityFrameworkCore.Design 仅限EF Core 1.1:还添加MySql.Data.EntityFrameworkCore.Design包。 Microsoft.EntityFrameworkCore.Tools版本1.1.6(适用于EF Core 1.1)和Microsoft.EntityFrameworkCore.Tools版本2.0.3(适用于EF Core 2.0) 注 .NET工具包含在.NET Core 2.1 SDK中,EF Core 2.1不需要或不支持这些工具。如果这是升级,请从.csproj文件(本例中为2.0.3版)中删除对该包的引用:
数据库创建实体和sakila
(调整连接字符串值以匹配用户=和密码=选项的设置):DbContext
尽管Oracle说明说EF Core 2.1不需要Microsoft.EntityFrameworkCore.Tools,但我安装了与EF 2.2兼容的2.2.0版,对我有效的解决方案是在Package Manager控制台中运行以下命令:
PM> Install-Package Microsoft.EntityFrameworkCore -Version 2.1.11
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.11
确保版本与错误消息中的版本匹配在我的情况下,我遇到以下错误:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.
检查以下站点提供的版本:
对特定的版本使用命令行、Cmd或PowerShell:
dotnet工具更新--全局dotnet ef--版本3.1.0
或用于最新版本的使用(也适用于重新安装):
dotnet工具更新——像Martin一样的全局dotnet ef
对特定版本使用命令行、Cmd或PowerShell:
dotnet工具更新--全局dotnet ef--版本3.1.0
或用于最新版本(也适用于重新安装):
dotnet工具更新--全局dotnet ef
但是,我的电脑有问题:
“在运行命令(不指定任何版本)时,我遇到以下错误:工具'dotnet ef'由于以下原因无法更新:
The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>