System.InvalidOperationException
HResult=0x80131509
Message=Failed to compare two elements in the array.
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource, Exception e)
at System.Collections.Generic.ArraySortHelper`1.Sort(Span`1 keys, Comparison`1 comparer)
at System.Linq.EnumerableSorter`2.QuickSort(Int32[] keys, Int32 lo, Int32 hi)
at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
at System.Linq.OrderedEnumerable`1.SortedMap(Buffer`1 buffer)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__19.MoveNext()
at System.Linq.Enumerable.SelectIPartitionIterator`2.MoveNext()
at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalModel.Create(IModel model, IRelationalAnnotationProvider relationalAnnotationProvider, IRelationalTypeMappingSource relationalTypeMappingSource, Boolean designTime)
at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelRuntimeInitializer.<>c__DisplayClass4_0.<InitializeModel>b__0()
at Microsoft.EntityFrameworkCore.RelationalModelExtensions.<>c.<GetRelationalModel>b__4_0(Func`1 f)
at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.<>c__30`2.<GetOrAddRuntimeAnnotationValue>b__30_0(String n, ValueTuple`3 t)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.GetOrAddRuntimeAnnotationValue[TValue,TArg](String name, Func`2 valueFactory, TArg factoryArgument)
at Microsoft.EntityFrameworkCore.RelationalModelExtensions.GetRelationalModel(IModel model)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.GetCreateTablesCommands(MigrationsSqlGenerationOptions options)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.CreateTables()
at EFCore9Bug.Program.Main(String[] args) in C:\Users\robbieg\source\repos\EFCore9Bug\EFCore9Bug\Program.cs:line 20
This exception was originally thrown at this call stack:
System.Collections.Comparer.Compare(object, object)
System.Collections.Generic.GenericComparer<T>.Compare(T, T)
System.Linq.EnumerableSorter<TElement, TKey>.CompareAnyKeys_DefaultComparer_NoNext_Ascending(int, int)
System.Collections.Generic.ArraySortHelper<T>.SwapIfGreater(System.Span<T>, System.Comparison<T>, int, int)
System.Collections.Generic.ArraySortHelper<T>.IntroSort(System.Span<T>, int, System.Comparison<T>)
System.Collections.Generic.ArraySortHelper<T>.IntrospectiveSort(System.Span<T>, System.Comparison<T>)
System.Collections.Generic.ArraySortHelper<T>.Sort(System.Span<T>, System.Comparison<T>)
Inner Exception 1:
ArgumentException: At least one object must implement IComparable.
File a bug
In EFCore 9 RC1 I'm getting a System.InvalidOperationException when my DbContext has multiple HasDbFunction calls.
In EF8 it works fine. If I limit it to 1 HasDbFunction(), it also works.
Include your code
Minimum reproducable project: EFCore9Bug.zip
Include stack traces
Include provider and version information
EF Core version: 9 RC1 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 8.0