简体   繁体   English

检测到 Microsoft.EntityFrameworkCore.Install 的版本冲突

[英]Version Conflict detected for Microsoft.EntityFrameworkCore.Install

I am getting the following error when adding an asp.net core api to an existing project I am working on.将 asp.net core api 添加到我正在处理的现有项目时,出现以下错误。

"Version Conflict detected for Microsoft.EntityFrameworkCore.Install/reference Microsoft.EntityFrameworkCore 2.2.1 directly to project to resolve this issue" “为 Microsoft.EntityFrameworkCore.Install/reference Microsoft.EntityFrameworkCore 2.2.1 直接检测到版本冲突以解决此问题”

I tried to add the Nuget package but get further version conflicts across a number of different packages and the process always fails.我尝试添加 Nuget 包,但在许多不同的包中出现了进一步的版本冲突,并且该过程总是失败。 At first I thought this may be an issue with my project so I started a new solution from scratch and managed to replicate the issue with a few simple steps.起初我认为这可能是我的项目的一个问题,所以我从头开始一个新的解决方案,并通过几个简单的步骤设法复制了这个问题。

  1. Create a new solution (EFDemo)创建一个新的解决方案 (EFDemo)
  2. Add a new .net Core class library to the solution called EFDemo.BL向名为 EFDemo.BL 的解决方案添加一个新的 .net Core 类库
  3. Add the following Nuget packages to project EFDemo.BL (as I'm using an existing database for my new project)将以下 Nuget 包添加到项目 EFDemo.BL(因为我正在为我的新项目使用现有数据库)
  4. Microsoft.EntityFrameworkCore.SqlServer (v2.2.1) Microsoft.EntityFrameworkCore.SqlServer (v2.2.1)
  5. Microsoft.EntityFraneworkCore.Tools (v2.2.1) Microsoft.EntityFraneworkCore.Tools (v2.2.1)
  6. Add a new .net core web application called EFDemo.Api and select the API project template.添加一个名为 EFDemo.Api 的新 .net 核心 Web 应用程序并选择 API 项目模板。
  7. Add a reference from EFDemo.BL to EFDemo.Api.添加从 EFDemo.BL 到 EFDemo.Api 的引用。
  8. Build and see the failure.构建并查看失败。

I have reviewed the following post but its solution does not work for me as I have no reference to "Microsoft.EntityFrameworkCore" in any of my csproj files.我已经查看了以下帖子,但它的解决方案对我不起作用,因为我在任何 csproj 文件中都没有提到“Microsoft.EntityFrameworkCore”。 Version conflict detected for NuGet packages . 检测到 NuGet 包的版本冲突

I have also reinstalled .net SDK, rebooted a million times and still can't understand what the issue is.我还重新安装了 .net SDK,重新启动了一百万次,但仍然无法理解问题是什么。

I have encountered the same error recently.我最近遇到了同样的错误。

What I have done to sort this out:我做了什么来解决这个问题:

Installed .Net Core 2.2 SDK安装.Net Core 2.2 SDK

Then in my project I have changed in all .csproj files:然后在我的项目中,我在所有 .csproj 文件中进行了更改:

  <PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

whereas before it was:而在此之前:

      <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

This helped straight away and the error dissapeared.这立即有所帮助,错误消失了。

The answer to this is quite difficult to catalog because I made many changes while trying to figure this out.对此的答案很难编目,因为我在试图弄清楚这一点时做了很多更改。 In the end, I believe the following steps fixed my issue:最后,我相信以下步骤解决了我的问题:

  • Upgrade VS to the latest version (v15.9.3)升级VS到最新版本(v15.9.3)
  • Uninstall both .Net Core 2.1 and 2.2 SDKs (my project was using 2.1 at the time)卸载 .Net Core 2.1 和 2.2 SDK(我的项目当时使用 2.1)
  • Install .Net Core 2.2 SDK安装 .Net Core 2.2 SDK
  • Convert all projects in my solution to use .Net Core 2.2 (A pain. I wish there was a Retarget All function!)将我的解决方案中的所有项目转换为使用 .Net Core 2.2(很痛苦。我希望有一个 Retarget All 功能!)
  • Reboot, Clean, Build and it works.重新启动、清理、构建和它的工作原理。 Phew.呼。

Now to do some work instead of fighting with my tools!现在做一些工作而不是用我的工具战斗!

For me, it helped this article, it was a very simple change on the configuration, which I forgot to change:对我来说,它对这篇文章有帮助,这是对配置的一个非常简单的更改,我忘记更改了:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

https://dotnetcoretutorials.com/2018/11/18/how-to-target-net-core-2-2/ https://dotnetcoretutorials.com/2018/11/18/how-to-target-net-core-2-2/

I am not sure what package you have installed in your project.我不确定您在项目中安装了什么包。

But now days visual studio add just one nuget packages which includes all of required package for asp.net core application.但是现在,visual studio 只添加了一个 nuget 包,其中包括 asp.net 核心应用程序所需的所有包。

Try installing this package and remove all other package and see it that works for you.尝试安装此软件包并删除所有其他软件包,看看它是否适合您。

Microsoft.AspNetCore.All微软.AspNetCore.All

This way you will not have version conflict at least within Microsoft packages.这样你至少不会在 Microsoft 包中发生版本冲突。 You can then verify other external package that you might have installed which is causing problem.然后,您可以验证您可能已安装的其他导致问题的外部包。

I fixed this just installing .NET Core 2.2 and changing TargetFramework tag to netcoreapp2.我修复了这个问题,只是安装了 .NET Core 2.2 并将 TargetFramework 标记更改为 netcoreapp2。

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>

这对我有帮助并且让我感到沮丧

   <TargetFramework>netcoreapp2.2</>

I had followed the steps to solve my problem我已经按照步骤解决了我的问题

  1. Download and install the latest framework (dotnet core 2.2 in my case)下载并安装最新的框架(在我的例子中是 dotnet core 2.2)
  2. Set the project target framework to highest (dotnet core 2.2 in my case) from project properties从项目属性中将项目目标框架设置为最高(在我的情况下为 dotnet core 2.2)
  3. Clean solution 4 Rebuild solution清洁解决方案 4 重建解决方案
  4. Update any version disputes (optional)更新任何版本争议(可选)
  5. Rebuild and save.重建并保存。

Hope this helps.希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 .NetCore 2.2 中检测到 Microsoft.EntityFrameworkCore.Install Reference 3.1.2 的版本冲突问题? - Issue with Version Conflict detected for Microsoft.EntityFrameworkCore.Install Referance 3.1.2 in .NetCore 2.2? 升级到 ASP.NET Core 5.0 时 Microsoft.EntityFrameworkCore.Relational 的版本冲突 - Version conflict for Microsoft.EntityFrameworkCore.Relational when upgrading to ASP.NET Core 5.0 检测到 NuGet 包的版本冲突 - Version conflict detected for NuGet packages 错误NU1107版本冲突检测到Microsoft.CodeAnalysis.Common - Error NU1107 Version conflict detected for Microsoft.CodeAnalysis.Common 无法从 Nuget 包管理器安装 Microsoft.EntityFrameworkCore - Not able to install Microsoft.EntityFrameworkCore from Nuget Package Manager 无法解析包“Microsoft.EntityFrameworkCore.Tools.DotNet”的版本 - Version for package `Microsoft.EntityFrameworkCore.Tools.DotNet` could not be resolved 程序集&#39;Microsoft.EntityFrameworkCore.Design,Version = 1.1.0.0中找不到入口点 - Entry point not found in assembly 'Microsoft.EntityFrameworkCore.Design, Version=1.1.0.0 检测到Newtonsoft.Json的版本冲突。 直接安装/参考Newtonsoft.Json 11.0.2(Azure功能视觉工作室) - Version conflict detected for Newtonsoft.Json. Install/reference Newtonsoft.Json 11.0.2 directly (Azure functions visual studio) Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException - Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException 在单元测试项目中检测到NU1107版本冲突 - NU1107 Version conflict detected in Unit Test project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM