简体   繁体   中英

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.

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.

Add this to the project containing your Configuration file.

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

You should now be able to execute ef commands.

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