【发布时间】: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