1

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?

4
  • do you have .core 2.1.2 framework?
    – Vivek Nuna
    Sep 1, 2018 at 13:05
  • @viveknuna yes I have. Sep 3, 2018 at 14:46
  • I think you can raise bug in EF Core
    – Vivek Nuna
    Sep 3, 2018 at 15:22
  • 2
    I resolve the problem adding <RuntimeIdentifier>osx.10.12-x64</RuntimeIdentifier> inside the <PropertyGroup> tag Feb 19, 2019 at 16:38

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.