Open KillerBoogie opened 3 days ago
For issue #34750 I installed v9.0 rc1 to test. I also tested this issue. The problem still exists with rc1.
@KillerBoogie we need a full repro to effectively investigate this problem. It's not immediately obvious what's going on here. I tried to reverse-engineer the repro based on code you provided, but I was unsuccessful.
@maumar : I stripped down the project. You can access it at https://github.com/KillerBoogie/ef-core-join-query-bug/tree/main
Below is the relevant code. It is part of a bigger project. It is not easy and very time consuming to create a reduced working project. I hope the issue can be understood by the posted code.
This is the projection that causes the issue. It just tries to return location data with nested cover images. The image Uri, width and height is pulled from the Image collection. Therefore a join is created.
The projection creates 3 queries. The first 2 queries are sufficient and would return the correct result. The 3rd query is unnecessary. I don't understand why it is created. It leads to a wrong response.
Due to the wrong query the result causes an exception:
I also tried without SplitQuery. The result again has an additional
LEFT JOIN
that makes no sense.The
Location
object has a list ofImageItems
.ImageItems
link to images from the Image collection with additional properties. ML<> and MLRequired<> are value objects that allow storing text in different languages. LocationName and Address are also value objects.This is the EF Core configuration for Location. Since we use guids as ids we add a technical cluster key (TId).
Image Configuration:
EF Core version: 8.0.8 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: NET 8.0 Operating system: Win 11 Visual Studio 2022 17.11.4