Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidOperationException with multiple HasDbFunction in 9 RC1 #34672

Closed
rgroenewoudt opened this issue Sep 13, 2024 · 1 comment
Closed

InvalidOperationException with multiple HasDbFunction in 9 RC1 #34672

rgroenewoudt opened this issue Sep 13, 2024 · 1 comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression type-bug
Milestone

Comments

@rgroenewoudt
Copy link

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

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.

Include provider and version information

EF Core version: 9 RC1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0

@rgroenewoudt
Copy link
Author

The issue might be related to duplicate naming with HasName()

@AndriySvyryd AndriySvyryd self-assigned this Sep 14, 2024
@AndriySvyryd AndriySvyryd modified the milestones: 10.0.0, 9.0.0 Sep 19, 2024
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 19, 2024
@AndriySvyryd AndriySvyryd removed their assignment Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression type-bug
Projects
None yet
Development

No branches or pull requests

2 participants