Skip to content

[release/10.0] Fix ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0#38045

Open
Copilot wants to merge 1 commit intorelease/10.0from
copilot/fix-complexproperty-nullable-issue
Open

[release/10.0] Fix ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0#38045
Copilot wants to merge 1 commit intorelease/10.0from
copilot/fix-complexproperty-nullable-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Fixes #38043

Description

Upgrading from EF Core 9.0 to 10.0 with complex properties causes false PendingModelChangesWarning during MigrateAsync and spurious migrations.

The previous fix (#37690) for this included a guard that was incorrect and the fix didn't apply for most snapshots.

Customer impact

When upgrading from EF Core 9.x to 10.0 with complex properties:

  • MigrateAsync() throws PendingModelChangesWarning at startup, blocking the application
  • dotnet ef migrations add generates spurious AlterColumn with oldNullable: true

Workaround: suppress RelationalEventId.PendingModelChangesWarning via ConfigureWarnings, or generate and revert the spurious migration to update the snapshot model. The workaround is discoverable from the exception message.

How found

Customer reported on EF 10.0.5.

Regression

Yes, regression from EF Core 10.0.0 when optional complex property support was added. The first fix attempt (PR #37690, commit c214374) was incomplete.

Testing

Added unit test

Risk

Very low. The fix removes an incorrect condition from a guard clause — a one-line change in design-time code.

Copilot AI changed the title [WIP] Fix ComplexProperty treatment as nullable after EF Core update Fix ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0 Apr 4, 2026
Copilot AI requested a review from AndriySvyryd April 4, 2026 05:38
@AndriySvyryd
Copy link
Copy Markdown
Member

@copilot Update progress using the servicing template

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot Update progress using the servicing template

Updated the PR description with the servicing template format, including Description, Customer impact, How found, Regression, Testing, and Risk sections.

Fix complex property nullability for pre-10.0 snapshots

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
@AndriySvyryd AndriySvyryd force-pushed the copilot/fix-complexproperty-nullable-issue branch from 4075768 to c233e99 Compare April 8, 2026 16:25
@AndriySvyryd AndriySvyryd changed the base branch from main to release/10.0 April 8, 2026 16:25
@AndriySvyryd AndriySvyryd changed the title Fix ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0 [release/10.0] Fix ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0 Apr 8, 2026
@AndriySvyryd AndriySvyryd marked this pull request as ready for review April 8, 2026 16:27
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner April 8, 2026 16:27
Copilot AI review requested due to automatic review settings April 8, 2026 16:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts EF Core design-time snapshot processing to ensure complex properties from EF Core 8.x/9.x snapshots are treated as non-nullable when loaded in EF Core 10.0, addressing false model-diff detection caused by property-bag complex types using Dictionary<string, object> as the snapshot CLR type.

Changes:

  • Removed the !complexProperty.ClrType.IsNullableType() guard so the pre-10 snapshot fix applies to property-bag complex properties.
  • Added a regression test covering property-bag complex property nullability update through SnapshotModelProcessor.

Reviewed changes

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

File Description
src/EFCore.Design/Migrations/Internal/SnapshotModelProcessor.cs Broadens the pre-10 snapshot nullability fix to apply regardless of complex property CLR type.
test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs Adds coverage for property-bag complex property nullability fixup when processing 9.x snapshots.

@AndriySvyryd AndriySvyryd requested a review from artl93 April 8, 2026 19:06
@AndriySvyryd
Copy link
Copy Markdown
Member

@artl93

@roji roji assigned AndriySvyryd and unassigned roji Apr 9, 2026
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.

ComplexProperty treated as nullable after update from EF Core 9.0 to 10.0.5

5 participants