Skip to content

Fix repeated seed-data updates for list properties - #4024

Merged
roji merged 2 commits into
mainfrom
roji-issue-3635-triage
Oct 18, 2026
Merged

roji merged 2 commits into
mainfrom
roji-issue-3635-triage

Conversation

@roji

@roji roji commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Unchanged seeded List<string> properties produce redundant UpdateData operations because migrations use the key/provider comparer rather than the element-wise value comparer.

Construct element-wise collection key comparers from the element key comparer, adapting them to the collection CLR type. This also preserves structural hashing for binary-array keys. Add regression coverage for unchanged and modified lists and arrays, and equality/hash consistency for binary collections.

Fixes #3635

Use the collection value comparer for key comparisons and adapt it to the collection CLR type. Add regression coverage for unchanged and modified lists and arrays.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3c4821db-381a-4b52-8547-0bb8ea084cb0
Copilot AI balanced review requested due to automatic review settings October 18, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reusing the value comparer introduces inconsistent hashing for content-equal binary-array keys, which can break identity-map lookups.

1 open issue
What changed in this PR

Addresses #3635 by using element-wise collection comparison to avoid redundant seed-data updates in migrations.

Changes:

  • Adapts the collection comparer to the mapped CLR type and reuses it for keys.
  • Adds regression tests for unchanged and modified lists and arrays.
File Description
test/​EFCore.PG.Tests/​Migrations/​NpgsqlMigrationsModelDifferTest.cs Tests collection seed-data differences.
src/​EFCore.PG/​Storage/​Internal/​Mapping/​NpgsqlArrayTypeMapping.cs Updates collection comparer configuration.

Review effort: Balanced

Construct collection key comparers from element key comparers rather than value comparers. Cover equal hashes for independently allocated binary arrays and lists.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3c4821db-381a-4b52-8547-0bb8ea084cb0
Copilot AI balanced review requested due to automatic review settings October 18, 2026 13:13
roji added a commit that referenced this pull request Oct 18, 2026
Backport source correction cd7d820 from #4024. Build the collection key comparer from the element key comparer and cover matching hashes for independently allocated binary arrays and lists.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c915897d-780d-411c-9e44-96717dd39e19
roji added a commit that referenced this pull request Oct 18, 2026
Backport the #4024 correction: build collection key comparers from element key comparers, preserving structural equality and hashing for binary array/list elements.

(cherry picked from commit cd7d820)

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 85e067fd-39b0-4a09-8247-395a5d886a3f

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
1 resolved since last review

Review effort: Lite

@roji
roji merged commit 4f66323 into main Oct 18, 2026
24 of 26 checks passed
@roji
roji deleted the roji-issue-3635-triage branch October 18, 2026 15:58
roji added a commit that referenced this pull request Oct 18, 2026
* [9.0] Fix repeated seed-data updates for list properties

Backport #4024 (8fd6510). Reuse the element-wise collection comparer for key comparisons and retype its expressions to the mapped collection CLR type with the EF 9 comparer APIs. Preserve regression coverage for unchanged and modified lists and arrays.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c915897d-780d-411c-9e44-96717dd39e19

* [9.0] Preserve structural element hashing for collection keys

Backport source correction cd7d820 from #4024. Build the collection key comparer from the element key comparer and cover matching hashes for independently allocated binary arrays and lists.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c915897d-780d-411c-9e44-96717dd39e19

---------

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c915897d-780d-411c-9e44-96717dd39e19
roji added a commit that referenced this pull request Oct 18, 2026
* [8.0] Fix repeated seed-data updates for list properties

Backport #4024. Reuse the collection value comparer for key comparisons and adapt its expressions to the collection CLR type using the EF 8 comparer APIs.

Fixes #3635

(cherry picked from commit 8fd6510)

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 85e067fd-39b0-4a09-8247-395a5d886a3f

* [8.0] Preserve structural element hashing for collection keys

Backport the #4024 correction: build collection key comparers from element key comparers, preserving structural equality and hashing for binary array/list elements.

(cherry picked from commit cd7d820)

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 85e067fd-39b0-4a09-8247-395a5d886a3f

---------

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 85e067fd-39b0-4a09-8247-395a5d886a3f
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.

Repeated UpdateData for List<string> property with HasData and migrations

2 participants