Skip to content

Conversation

@AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Jul 29, 2025

Add complex property builder overloads for nullable structs

Part of #31376

cc @artl93

@AndriySvyryd AndriySvyryd requested a review from a team as a code owner July 29, 2025 23:57
@AndriySvyryd AndriySvyryd enabled auto-merge (squash) July 29, 2025 23:58
Copy link

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 fixes an issue with null complex property values during SaveChanges when using table splitting by adding support for nullable struct complex properties. The main purpose is to properly handle nullable value types in complex property configurations and update tracking.

Key changes:

  • Add complex property builder overloads that accept nullable struct expressions (Expression<Func<TEntity, TProperty?>>)
  • Update complex type resolution to unwrap nullable types correctly
  • Fix column modification logic to handle null complex properties in table splitting scenarios

Reviewed Changes

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

Show a summary per file
File Description
src/EFCore/Metadata/Internal/InternalTypeBaseBuilder.cs Updates complex type resolution to unwrap nullable types using UnwrapNullableType()
src/EFCore/Metadata/Builders/EntityTypeBuilder*.cs Adds overloaded methods for nullable struct complex properties and collections
src/EFCore/Metadata/Builders/ComplexPropertyBuilder*.cs Adds overloaded methods for nullable struct complex properties within complex types
src/EFCore/Metadata/Builders/ComplexCollectionBuilder*.cs Adds overloaded methods for nullable struct complex collections within complex types
src/EFCore.Relational/Update/ColumnModification.cs Updates GetCurrentValue to handle null complex properties in table splitting
test/EFCore.Specification.Tests/ComplexTypesTrackingTestBase.cs Updates tests to use nullable License properties and adds new test cases
Various test files Refactors test inheritance to use relational base classes and removes nullable disable pragmas
Comments suppressed due to low confidence (1)
@cincuranet
Copy link
Contributor

FYI, the failures are from InMemory.

Fix null complex property values in SaveChanges for table splitting Part of #31376
@AndriySvyryd AndriySvyryd merged commit 65bb90c into main Jul 30, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the SaveNullComplex branch July 30, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants