Skip to content

Conversation

@thromel
Copy link
Contributor

@thromel thromel commented Jan 25, 2026

Summary

Reloading an entity with a nullable complex property set to null in the store could throw a conceptual-null error when the complex contained required members. The store value projection was reading non-nullable value types, losing nulls and causing the complex to be treated as non-null.

Fix

  • Preserve nulls for value-type members inside nullable complex properties when projecting store values.
  • Compute nullable-complex null flags from store values and pass them into ArrayPropertyValues so reload skips nested required members when the complex is null.
  • Add regression coverage for reload on optional complex properties.

Closes issue when merged

Test Plan

  • Sqlite: reload optional complex property with null store values (PropertyValuesSqliteTest / Reloading_optional_complex_property_with_null_does_not_throw)
  • InMemory: reload optional complex property with null store values (PropertyValuesInMemoryTest / Reloading_optional_complex_property_with_null_does_not_throw)
  • SqlServer: reload optional complex property with null store values (PropertyValuesSqlServerTest / Reloading_optional_complex_property_with_null_does_not_throw)

@thromel thromel requested a review from a team as a code owner January 25, 2026 02:40
@thromel thromel force-pushed the issue-37559-reload-nullable-complex branch from dd3d33e to d71bcfe Compare January 25, 2026 02:44
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.

EF 10: EntityEntry.ReloadAsync throws when nullable complex property is null

2 participants