Skip to main content

The type initializer for 'Microsoft.EntityFrameworkCore.EnumerableMethods' threw an exception - InvalidOperationException: Sequence contains more than one matching element

· 2 min read

net6.0

MySql.Data.EntityFrameworkCore [Version=8.0.22]

This package has been deprecated.

Microsoft.EntityFrameworkCore

Upgrade Microsoft.EntityFrameworkCore to 6.0.1

Install the new package "MySql.EntityFrameworkCore" version 5.0.8 to resolved

    System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Microsoft.EntityFrameworkCore.EnumerableMethods' threw an exception.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.EnumerableMethods.get_AnyWithPredicate()
at Microsoft.EntityFrameworkCore.Query.Internal.AllAnyToContainsRewritingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Any[TSource](IQueryable`1 source)
at Q1.AutoOps.ResCleaner.Services.RabbitMQCleaner.StartAsync(CancellationToken cancellationToken) in D:\Projects\DevOps\AutoOps\Q1.AutoOps.ResCleaner\src\Q1.AutoOps.ResCleaner\Services\RabbitMQCleaner.cs:line 69
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Program.<Main>$(String[] args) in D:\Projects\DevOps\AutoOps\Q1.AutoOps.ResCleaner\src\Q1.AutoOps.ResCleaner\Program.cs:line 29

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
InvalidOperationException: Sequence contains more than one matching element

Reference: - https://docs.microsoft.com/en-us/answers/questions/622611/net-6-upgrade.html

ClustrMaps