【问题标题】:Version conflict for Microsoft.EntityFrameworkCore.Relational when upgrading to ASP.NET Core 5.0升级到 ASP.NET Core 5.0 时 Microsoft.EntityFrameworkCore.Relational 的版本冲突
【发布时间】:2021-03-04 08:47:52
【问题描述】:

将我的项目从 ASP.NET Core 3.1 迁移到 5.0 后,我遇到了这个问题:

错误 NU1107 检测到版本冲突 Microsoft.EntityFrameworkCore.Relational。

将 Microsoft.EntityFrameworkCore.Relational 5.0.0 直接安装/引用到项目 Alpha.Web.App 以解决此问题。

Alpha.Web.App -> Microsoft.EntityFrameworkCore.Tools 5.0.0 -> Microsoft.EntityFrameworkCore.Design 5.0.0 -> Microsoft.EntityFrameworkCore.Relational (>= 5.0.0)

Alpha.Web.App -> Pomelo.EntityFrameworkCore.MySql 3.2.4 -> Microsoft.EntityFrameworkCore.Relational (>= 3.1.8 &&

E:\Projects\Alpha\Alpha.Web.App\Alpha.Web.App.csproj 1

我该如何解决?

Alpha.Web.App.csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <UserSecretsId>XXXXXXuser secret idXXXXXXXX</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
          <!-- ...-->
  </ItemGroup>

  <ItemGroup>
          <!-- ...-->
  </ItemGroup>

  <ItemGroup>
          <!-- ...-->
  </ItemGroup>

  <ItemGroup>
    <None Remove="migrations.sql" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="5.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="5.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="5.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" />
    
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.0" Condition="'$(Configuration)' == 'Debug'" />
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>


    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="5.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
    <PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.0" />
    <PackageReference Include="NLog.Extensions.Logging" Version="1.6.5" />
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.4" />
    <PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.5" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Alpha.DataAccess\Alpha.DataAccess.csproj" />
    <ProjectReference Include="..\Alpha.Infrastructure\Alpha.Infrastructure.csproj" />
    <ProjectReference Include="..\Alpha.LoggerService\Alpha.LoggerService.csproj" />
    <ProjectReference Include="..\Alpha.Models\Alpha.Models.csproj" />
    <ProjectReference Include="..\Alpha.Services\Alpha.Services.csproj" />
  </ItemGroup>

  <ItemGroup>
   <!-- ...-->
  </ItemGroup>

  <ItemGroup>
   <!-- ...-->
  </ItemGroup>

</Project>

【问题讨论】:

  • 您是否已将 Entity Framework Core 升级到最新版本?
  • 是的,我做到了。你可以看到。
  • 我已经删除了 Pomelo.EntityFrameworkCore.MySql,现在它运行良好。目前没有兼容 .net5.0 的 Pomelo 包
  • 将其作为答案发布,这些天人们正在对其进行测试,他们可能会关注此帖子。

标签: c# asp.net-core asp.net-core-3.1 .net-5 asp.net-core-5.0


【解决方案1】:

我已经删除了Pomelo.EntityFrameworkCore.MySql,现在它运行良好。 目前没有兼容 .NET 5 的 Pomelo 包:

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#schedule-and-roadmap

【讨论】:

    【解决方案2】:

    只需安装一个更新的兼容 Pomelo 包。

    Pomelo.EntityFrameworkCore.MySql (v5.0.0)实际上与Microsoft.EntityFrameworkCore.Relational (v5.0.x)兼容

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 1970-01-01
      • 2021-10-17
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      相关资源
      最近更新 更多