Skip to content

Fix shared type entity type name generattion in model snapshot#38611

Open
AndriySvyryd wants to merge 1 commit into
mainfrom
Issue36180
Open

Fix shared type entity type name generattion in model snapshot#38611
AndriySvyryd wants to merge 1 commit into
mainfrom
Issue36180

Conversation

@AndriySvyryd

Copy link
Copy Markdown
Member

Fixes #36180

Copilot AI review requested due to automatic review settings July 11, 2026 03:48
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner July 11, 2026 03:48
@AndriySvyryd AndriySvyryd removed the request for review from a team July 11, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes snapshot generation for owned entity types with shared CLR types so that regenerating a model snapshot from a model that was itself built from a snapshot (e.g., during Remove-Migration) doesn’t produce corrupted owned type names in HasForeignKey(...) calls (Issue #36180).

Changes:

  • Adjust CSharpSnapshotGenerator.GetFullName to better normalize owned entity type names when HasSharedClrType is true (including handling names derived from ShortName()).
  • Add a regression test covering an owned collection containing a one-to-one reference, verifying snapshot round-tripping stability and successful compilation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs Adds a regression test to ensure snapshot regeneration doesn’t corrupt owned type names for one-to-one relationships inside owned collections.
src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs Updates owned entity type name normalization logic for shared CLR types to prevent duplicated/incorrect owned type names in generated snapshots.

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.

Remove-Migration is corrupting the DbContextModelSnapshot

2 participants