EF Core migration errors with the located assembly's manifest definition does not match the assembly reference

.net-core c# entity-framework-core

Question

I'm trying to generate a database from the terminal of VS code using SQL Operations Studio, whenever I try to generate a migration this error occurs.

dotnet ef migrations add init

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly '/usr/local/share/dotnet/sdk/2.1.401/DotnetTools/dotnet-ef/2.1.2/tools/netcoreapp2.1/any/tools/netcoreapp2.0/any/ef.dll'. The located assembly's manifestdefinition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This is how my .csproj looks like now

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.2" />
  </ItemGroup>
</Project>

Any workaround for this?

1
1
8/31/2018 8:18:43 PM

Popular Answer

This can also happen if you have Microsoft.EntityFrameworkCore.Design package added to the wrong project.

I added the package to project A (netcore). Later I decided to make project A to target netstandard. I then created Project B (netcore) which reference project A (now netstandard).

When I try to create migration in project B the build succeeds but migration would fail because Microsoft.EntityFrameworkCore.Design was referenced in A instead of B. Moving the nuget reference to B fixes the problem.

0
3/11/2020 3:41:01 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow