-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query OrderBy(MAX) followed by ThenBy(RelatedEntity.Name) causes InvalidOperationException #19359
Comments
@psryan - Does it fail for SqlServer? Can you post stack-trace for SqlServer? |
@smitpatel - Yes it fails for SQL Server. Stack trace follows from Dev environment running in Debug with IISExpress:
|
@psryan - Thanks. |
A little more info and I've made a little bug fix in Repro project code Output from .Net Core 2.2 (Working)Order on MAX first, followed by Customer.CustomerName:
Output from .Net Core 3.1 (Not Working)Order on MAX first, followed by Customer.CustomerName:
Using the work-around by explicitly using .Join() for each entity referenced in the .ThenBy():
|
Duplicate of #18904 |
@smitpatel - I just installed .Net Core 3.1.1 SDK and tested this issue again. It still fails. Are you sure this is a duplicate to #18904 or has Core 3.1.1 not addressed this issue? |
#18904 has been fixed in 5.0 milestone. |
The Issue
Issue encountered after upgrading from Core 2.2 to Core 3.1 (LTS) regarding EntityFramework Core 3.1 queries. Was working fine in Core 2.2.
When using OrderBy with an aggregate (e.g. Max, Min, Count, etc) followed by ThenBy with a related entity property, I get "System.InvalidOperationException ... EF.Property called with wrong property name". In Prod, I use SQL Server and dynamic ordering via System.Linq.Dynamic.Core as the users can choose which fields to order by, but I have reproduced the issue using an InMemory database with direct OrderBy().ThenBy() in the attached cut down repro project.
Example of where the exception is raised in the repro project:
To reproduce
Download the attached simplified project and run it.
Exception details:
Further technical details
EF Core version: 3.1.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer & Microsoft.EntityFrameworkCore.InMemory
Target framework: .NET Core 3.1
Operating system: Windows Server 2016
IDE: Visual Studio 2019 16.4.2
CrashRepro OrderBy(Max)ThenBy(Related).zip
The text was updated successfully, but these errors were encountered: