Home > other >  Entity Framework 6.3 in .NET6
Entity Framework 6.3 in .NET6

Time:07-14

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?

CodePudding user response:

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.

  • Related