#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

How to fix another weird Entity Framework Core dependency issue?

koskila
Reading Time 2 min
Word Count 348 words
Comments 0 comments
Rating n/a (0 votes)
View

Okay - so that's a non-descriptive title if I've ever written one - I apologize for that! I just couldn't figure out a way to shorten the error when "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" is referencing "Microsoft.AspNetCore.Http.Abstractions", and even though you're not referencing that dependency directly, you get an error where you have both 3.x and 5.x or 6.x major versions of the assembly in use. Which, in layman's terms, is no good.

What a weird case - not something you would usually expect to run into! But as usual, the fix is simple :)

Background

When using Entity Framework Core in your project and enabling diagnostic logging/settings, your project suddenly stops building and you get an error like this:

CS1705 Assembly 'Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore' with identity 'Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' uses 'Microsoft.AspNetCore.Http.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Http.Abstractions' with identity 'Microsoft.AspNetCore.Http.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

In Visual Studio, it will look somewhat like this:

So, what do?

Solution

Just a couple of things to check:

Time needed: 3 minutes.

How to fix referenced assembly version conflict with Microsoft.AspNetCore.Http.Abstractions when using Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore?

  1. Make sure you're not directly referencing a conflicting version of the assembly

    Start by making sure you're not intentionally (or accidentally, who knows?) referencing a conflicting version of the assembly.

    You can do this by checking Dependencies > Packages (and Dependencies > Assemblies, just in case) for any references to Microsoft.AspNetCore.Http.Abstractions with versions that are different from your EF Core version.

  2. Upgrade your dependencies

    This seems like a bug - it's probably fixed in later versions, so one of the things you could try is updating your dependencies.

  3. Remove app.UseDatabaseErrorPage() from your Startup

    The next step is to make sure you're not trying to use the app.UseDatabaseErrorPage() - for whatever reason, its implementation causes this assembly conflict!

    if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Get rid of this line below - I commented it away for clarity. //app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); }

  4. Rebuild and you should be good!

    After rebuilding, the error should be gone!


Did it work? Let me know in the comments -section below!

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-12T07:18:41Z