[Bug] EF Core InvalidOperationException on split query with FromSql join and collection Include
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C#
- スター
- 14.8k
- フォーク
- 3.5k
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 158
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/efcore のほかの issue
-
Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with Take対応中かも @Mohamedadel-prog が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
dotnet/efcore#39848 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
customer-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
Compiled model: generate a deterministic model ID対応中かも @rgroenewoudt が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 2 日以内に返信
-
customer-reported
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
area-VM-meta-mono untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
BattletechModders/ModTek#256 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/sqltoolsservice#2851 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
triage/untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
unoplatform/uno#26844 ·
メンテナーはふだん 1 日以内に返信