每当我想通过 NetFramework 4.8 项目上的 NuGet 将 EFCore 引用更新为版本 3 时,我都会收到此错误。
我确认我的机器上安装了 netcore 3.0 SDK。
Could not install package 'Microsoft.EntityFrameworkCore 3.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
这是 EF Core 3.0 中的重大突破性更改。但在 EF Core 3.1 中已修复。
从 3.0 开始,EF Core 以 .NET Standard 2.1 为目标,并将运行在
所有支持该标准的平台。这不包括.NET
框架。
EF Core 3.0 中包含的重大更改 https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes#ef-core-30-targets-net-standard-21-rather-than-net-standard-20
这是跟踪问题,其中包含有关此更改的大量背景信息:目标 .NET 标准 2.1 https://github.com/aspnet/EntityFrameworkCore/issues/15498
并且 .NET Framework 的未来版本计划不支持 .NET Standard 2.1。参见例如:
鉴于 .NET Standard 2.1 中的许多 API 添加都需要运行时
为了使更改有意义,.NET Framework 4.8 将保留
.NET Standard 2.0 而不是实现 .NET Standard 2.1。 .NET核心
3.0 以及即将推出的 Xamarin、Mono 和 Unity 版本将进行更新以实现 .NET Standard 2.1。
宣布 .NET 标准 2.1 https://devblogs.microsoft.com/dotnet/announcing-net-standard-2-1/.
因此,您必须跳转到 EF Core 3.1 和至少 .NET Framework。 4.7.2.
[UPDATE]
EF Core 3.1 重新引入了对 .NET Standard 2.0 的支持,而不是
需要 .NET Standard 2.1,就像 EF Core 3.0 的情况一样。这
意味着 EF Core 3.1 将在支持的 .NET Framework 版本上运行
标准。
.NET Framework 4.7.2 及更高版本完全支持 .NET Standard 2.0,EF Core 3.1 也是如此。看here https://learn.microsoft.com/en-us/dotnet/standard/net-standard为支持矩阵。https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-3-1-and-entity-framework-6-4/ https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-3-1-and-entity-framework-6-4/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)