Strongly-typed Configuration for .NET Core - with full Dependency Injection support
ASP.NET Core Web API Performance - Throughput for Upload and Download

Entity Framework Core Migrations: Assembly Version Mismatch

If you have switched your .NET Core project from xproj to csproj (MSBuild) and updated the nuget packages then you may run into an issue when executing some of the dotnet ef-commands.

I got the following error after executing dotnet ef migrations list:

Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The problem is that some of my (3rd party) dependencies are using version 1.1.0 and the others version 1.1.1. In a classic .NET 4.6 project we use assembly redirects to solve this kind of problems and the in .NET Core we do the same ...

Just create an app.config file with the following content:

<?xml version="1.0" encoding="utf-8"?>

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <assemblyIdentity name="Microsoft.EntityFrameworkCore" culture="neutral" publicKeyToken="adb9793829ddae60" />
                <bindingRedirect oldVersion="" newVersion="" />"
                <assemblyIdentity name="Microsoft.EntityFrameworkCore.Relational" culture="neutral" publicKeyToken="adb9793829ddae60" />
                <bindingRedirect oldVersion="" newVersion="" />"
                <assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" culture="neutral" publicKeyToken="adb9793829ddae60" />
                <bindingRedirect oldVersion="" newVersion="" />"

If you still getting errors than make sure you have the following items in your csproj-file

    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0">
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />



Feed You can follow this conversation by subscribing to the comment feed for this post.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)