Entity Framework | Sequence contains more than one matching element

You have net6.0 target framework which is still not released while you have installed EF6 which is a previous iteration Entity Framework (mainly used with legacy .NET Framework projects) and you also have EF Core (a modern iteration of it) but older version – 5.0 (which you are actually using for your context, see the using Microsoft.EntityFrameworkCore; statements there).

Try removing EntityFramework package and installing preview version of Microsoft.EntityFrameworkCore.SqlServer (possibly just updating to the latest 5 version also can help) and either removing completely or installing preview version of Microsoft.EntityFrameworkCore.Design. (Also I would recommend to update your SDK to rc and install rc versions of packages).

Or try removing the reference to EntityFramework (not Core one) and changing target framework to net5.0 (if you have it installed on your machine).

As for why do you see this exception – I would guess it is related to the new methods added to Queryable in .NET 6 which made one of this checks to fail.

TL;DR

As mentioned in the comments – update EF Core to the corresponding latest version (worked for 5.0 and 3.1) or update to .NET 6.0 and EF Core 6.

Leave a Comment