Fix seed data diffing when primary key column count changes - #38824
Open
AhmedSadek10 wants to merge 2 commits into
Open
Fix seed data diffing when primary key column count changes#38824AhmedSadek10 wants to merge 2 commits into
AhmedSadek10 wants to merge 2 commits into
Conversation
- Check primary key column counts before comparing columns - Add a test for expanding a primary key with seed data Fixes dotnet#35116
There was a problem hiding this comment.
Pull request overview
Fixes a migration scaffolding crash when diffing seed data for a table whose primary key column count changes between source and target models, by short-circuiting key mapping before per-column comparison.
Changes:
- In
MigrationsModelDiffer.DiffData, check primary key column counts before iterating/comparing key columns to avoid out-of-range indexing. - Add a regression test covering expanding a primary key when seed data is present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs | Adds a regression test for expanding a primary key with seed data. |
| src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs | Prevents invalid key-column mapping when PK column counts differ during seed diffing. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
AhmedSadek10
force-pushed
the
issue-35116-seed-data-key-expansion
branch
from
August 18, 2026 00:04
5bbae59 to
c4d2fe2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35116