简体   繁体   English

.NET6 中的实体框架 6.3

[英]Entity Framework 6.3 in .NET6

I'm having a problem using EF 6 (not EF Core) with .NET 6 everything works fine except when I try to add a migration.我在使用 .NET 6 的 EF 6(不是 EF Core)时遇到问题,一切正常,除非我尝试添加迁移。

I get the following error:我收到以下错误:

The type initializer for 'System.Data.Entity.Migrations.DbMigrationsConfiguration`1' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

What could be the cause of this?这可能是什么原因?

For other people still wanting to use EF 6.3 with .NET Core for legacy reasons.对于出于遗留原因仍希望将 EF 6.3 与 .NET Core 一起使用的其他人。

Add this to the project containing your Configuration file.将此添加到包含您的配置文件的项目中。

<PropertyGroup>
 <GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

You should now be able to execute ef commands.您现在应该能够执行 ef 命令。

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

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