[Bug] EF Core InvalidOperationException on split query with FromSql join and collection Include
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Start from the provided EF Core query and reproduce the InvalidOperationException in a test or small console sample using EF Core 10.0.10. Trace the relational query translation for FromSql, Join, Include, and AsSplitQuery() through the relational query components. The work is done when the split query no longer throws for the collection include and returns the expected entities with ORDetails loaded.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug description
Bug Summary
An unhandled System.InvalidOperationException occurs in Entity Framework Core when querying OR with OR.ORDetails included (AsSplitQuery()) via a FromSql join on @orIds.
Steps to Reproduce / Context
- FE Screen / User Action:
[Insert FE screen or action that triggers this request] - API Endpoint:
[Insert endpoint, e.g., POST /api/...] - Request Payload / Parameters:
[Insert sample payload, e.g., orIds, ClientId, WarehouseId]
Query Causing the Error
DbSet<JoinKey<long>>().FromSql(SELECT [Id] FROM @orIds, @p)
.Join(
inner: DbSet<OR>()
.IgnoreQueryFilters(),
outerKeySelector: e => e.Id,
innerKeySelector: e => e.ORId,
resultSelector: (_, e) => e)
.Where(e => (int?)e.ClientId == @_tenantInfo_ClientId)
.Where(e => (int?)e.WarehouseId == @_tenantInfo_WarehouseId)
.Include(x => x.ORDetails)
.AsSplitQuery()
### Your code
```csharp
DbSet<JoinKey<long>>().FromSql(SELECT [Id] FROM @orIds, @p)
.Join(
inner: DbSet<OR>()
.IgnoreQueryFilters(),
outerKeySelector: e => e.Id,
innerKeySelector: e => e.ORId,
resultSelector: (_, e) => e)
.Where(e => (int?)e.ClientId == @_tenantInfo_ClientId)
.Where(e => (int?)e.WarehouseId == @_tenantInfo_WarehouseId)
.Include(x => x.ORDetails)
.AsSplitQuery()
Stack traces
Microsoft.EntityFrameworkCore.Query: Debug: Including navigation: 'OR.ORDetails'.
Exception thrown: 'System.InvalidOperationException' in Microsoft.EntityFrameworkCore.Relational.dll
'Unable to translate a collection subquery in a projection since either parent or the subquery doesn't project necessary information required to uniquely identify it and correctly generate results on the client side. This can happen when trying to correlate on keyless entity type. This can also happen for some cases of projection before 'Distinct' or some shapes of grouping key in case of 'GroupBy'. These should either contain all key properties of the entity that the operation is applied on, or ...'
The thread '.NET TP Worker' (83024) has exited with code 0 (0x0).
Verbose output
EF Core version
10.0.10
Database provider
No response
Target framework
NET 10
Operating system
No response
IDE
No response
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.5k
- Merge trung bình
- 2 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 158
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/efcore
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with TakeCó thể đã có người làm @Mohamedadel-prog đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
dotnet/efcore#39848 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Compiled model: generate a deterministic model IDCó thể đã có người làm @rgroenewoudt đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/efcore
Issue tương tự
-
area-VM-meta-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
BattletechModders/ModTek#256 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/sqltoolsservice#2851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
triage/untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
unoplatform/uno#26844 ·
Maintainer thường phản hồi trong vòng 1 ngày