简体   繁体   中英

Version conflict for Microsoft.EntityFrameworkCore.Relational when upgrading to ASP.NET Core 5.0

After migrating my project from ASP.NET Core 3.1 to 5.0 I have encountered this problem:

Error NU1107 Version conflict detected for Microsoft.EntityFrameworkCore.Relational.

Install/reference Microsoft.EntityFrameworkCore.Relational 5.0.0 directly to project Alpha.Web.App to resolve this issue.

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 && < 5.0.0).

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

How can I solve it?

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>

I have removed Pomelo.EntityFrameworkCore.MySql and now it works well. At this moment there is no compatible Pomelo package for .NET 5:

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

Just install a newer compatible Pomelo package.

Pomelo.EntityFrameworkCore.MySql (v5.0.0) is actually compatible with the Microsoft.EntityFrameworkCore.Relational (v5.0.x)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM