.Net 6 Upgrade

Shashi 6 Reputation points
2021-11-10T17:42:40.487+00:00

Hi Team,

We are updating the .Net Core 3.1 framework to .Net 6 then we are getting this error.

System.TypeInitializationException: 'The type initializer for 'Microsoft.EntityFrameworkCore.EnumerableMethods' threw an exception.'

InvalidOperationException: Sequence contains more than one matching element


We have used a few libraries projects and its created with .Net Standard library 2.0

.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,125 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Max Calvin 21 Reputation points
    2021-11-16T10:04:29.887+00:00

    Hi @Shashi - I've had this issue when I tried to move to .net 6, turns out it just needed the EF nuget package updated to the latest version. Something about .net 6 and the older EF versions wasn't playing nicely.

    Not sure if you have the same problem but it's worth a try if you haven't upgraded it yet.

    Good luck!
    Max

    4 people found this answer helpful.

  2. Shan Nagarajan 0 Reputation points
    2023-04-19T17:31:55.1466667+00:00

    Need to update DB Project (dacpack) entity framework version, after updating below changes it is working.

        <PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.10" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.10">
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.10" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
    
    0 comments No comments