Skip to content

Fix duplicate joins when materializing writable projectables with includes#218

Merged
PhenX merged 1 commit into
masterfrom
claude/github-issue-217-9odp2y
Jul 20, 2026
Merged

Fix duplicate joins when materializing writable projectables with includes#218
PhenX merged 1 commit into
masterfrom
claude/github-issue-217-9odp2y

Conversation

@PhenX

@PhenX PhenX commented Jul 14, 2026

Copy link
Copy Markdown
Member

A writable [Projectable] property triggers a whole-entity re-projection so
the property can be populated during materialization. That re-projection read
every other mapped member through its compiler-generated backing field
(what EF's member metadata resolves auto-properties to). Reading a mapped
scalar or navigation through the backing field stops EF's navigation
expansion from recognizing it as a plain column/navigation, so EF instead
materializes the entire source entity -- including any Include-ed collection
navigation -- once per rewritten member, emitting one duplicate JOIN per
member (issue #217).

Read each member through its CLR property instead, and bind to the property
when it is settable so the projection keeps natural column names. EF then
treats scalars as columns and collapses the collection navigation into a
single join.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_016Xvb9UMRqFJKpocKCCeYcc

…ludes

A writable [Projectable] property triggers a whole-entity re-projection so
the property can be populated during materialization. That re-projection read
every other mapped member through its compiler-generated backing field
(what EF's member metadata resolves auto-properties to). Reading a mapped
scalar or navigation through the backing field stops EF's navigation
expansion from recognizing it as a plain column/navigation, so EF instead
materializes the entire source entity -- including any Include-ed collection
navigation -- once per rewritten member, emitting one duplicate JOIN per
member (issue #217).

Read each member through its CLR property instead, and bind to the property
when it is settable so the projection keeps natural column names. EF then
treats scalars as columns and collapses the collection navigation into a
single join.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Xvb9UMRqFJKpocKCCeYcc
@PhenX
PhenX merged commit 2f14a3a into master Jul 20, 2026
4 checks passed
@PhenX
PhenX deleted the claude/github-issue-217-9odp2y branch July 20, 2026 20:55
github-merge-queue Bot pushed a commit to DFE-Digital/teaching-record-system that referenced this pull request Jul 22, 2026
Updated
[EntityFrameworkCore.Projectables](https://github.com/EFNext/EntityFrameworkCore.Projectables)
from 6.0.4 to 6.0.6.

<details>
<summary>Release notes</summary>

_Sourced from [EntityFrameworkCore.Projectables's
releases](https://github.com/EFNext/EntityFrameworkCore.Projectables/releases)._

## 6.0.6

## What's Changed
* Preserve nullable typing for ignored null-conditional access in
coalesce expressions by @​PhenX with @​Copilot in
EFNext/EntityFrameworkCore.Projectables#212
* Fix duplicate joins when materializing writable projectables with
includes by @​PhenX in
EFNext/EntityFrameworkCore.Projectables#218


**Full Changelog**:
EFNext/EntityFrameworkCore.Projectables@v6.0.5...v6.0.6

## 6.0.5

## What's Changed
* Fix source generator crash when parameter type uses verbatim @ keyword
prefix by @​Copilot in
EFNext/EntityFrameworkCore.Projectables#208


**Full Changelog**:
EFNext/EntityFrameworkCore.Projectables@v6.0.4...v6.0.5

Commits viewable in [compare
view](EFNext/EntityFrameworkCore.Projectables@v6.0.4...v6.0.6).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=EntityFrameworkCore.Projectables&package-manager=nuget&previous-version=6.0.4&new-version=6.0.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Gunn <james@gunn.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants