Skip to content

Support complex properties on owned types - #39522

Merged
AndriySvyryd merged 7 commits into
dotnet:mainfrom
jeremy-morren:complex-properties-on-owned-types
Nov 21, 2026
Merged

AndriySvyryd merged 7 commits into
dotnet:mainfrom
jeremy-morren:complex-properties-on-owned-types

Conversation

@jeremy-morren

@jeremy-morren jeremy-morren commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #33170.

  • API: ComplexProperty/ComplexCollection on OwnedNavigationBuilder and OwnedNavigationBuilder<,>. Snapshots with b1.ComplexProperty(...) (e.g. from [ComplexType]) now compile.
  • Model building: complex properties survive an owned type being detached and re-attached (e.g. becoming shared-type); their complex type names are regenerated.
  • JSON column names: ToJson() without a name prefixes the JSON column with the ownership navigations when the owned type shares its owner's table or view (e.g. Owned_Address), like the columns of its other properties. The prefix is computed per table or view in GetContainerColumnName(StoreObjectIdentifier), so it doesn't depend on the order of ToJson() and ToTable(). ToJson() stores an empty container column name, which GetContainerColumnName resolves to the default (explicit names are used as-is). Snapshots emit ToJson() for the default.
  • Validation: complex properties aren't supported on owned types inside OwnsMany().ToJson(), which is deprecated (#37289); OwnsOne().ToJson() is supported.
  • Query: complex properties on owned types are bound for table-shared, separate-table, split and JSON owned references, including through pushdown and set operations.
  • Keys on complex types: for any entity type, owned or not, Distinct, set operations, entity equality with a parameter and Contains over a local collection now work when the key is declared on a complex type. A non-collection JSON complex property stays a reference over set operations, so it can be filtered and projected.
  • Update: for JSON owned references, a single modified scalar is patched in place, including through its complex properties. The whole owned document is written instead when a complex collection was also modified or the scalar is in a nullable complex property. ExecuteUpdate on these members throws the existing not-supported error.

Based on #39524 (includes that commit). Fixes #39523.

Tests:

  • Model building, including attribute-only [Owned] + [ComplexType], and default and explicit JSON column names for either order of ToJson() and ToTable()
  • Migrations: snapshot, differ, end-to-end
  • Compiled models and precompiled queries
  • Query/Associations/OwnedComplexProperties suite (SQL Server, SQLite, Cosmos): owned associates with complex nested associates
  • Cases that don't fit that model, in existing classes:
    • InheritanceComplexTypesQueryTestBase: TPH/TPT/TPC
    • EntitySplittingQueryTestBase
    • CustomConvertersTestBase: value converters and comparers
    • NonSharedModelBulkUpdatesTestBase: ExecuteUpdate
    • OwnedEntityQueryRelationalTestBase: table mappings, JSON (including JsonValueReaderWriter) and SaveChanges
    • ComplexTypeQueryRelationalTestBase: keys on complex types
    • RelationalModelValidatorTest.Json
  • Re-enabled the lazy-loading proxy tests that were waiting on Support complex properties on owned types #33170

Known limitations:

NB: AI did most of the heavily lifting for this PR.

@jeremy-morren
jeremy-morren requested a review from a team as a code owner November 4, 2026 14:56
Copilot AI balanced review requested due to automatic review settings November 4, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved JSON nullability defects can incorrectly exclude unmatched outer-join rows or trigger Debug assertions, while default-name handling can overwrite explicit container-column configuration.

3 open issues
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file
What changed in this PR

Adds complex-property and complex-collection support to owned types, addressing #33170’s migration snapshot compilation failure and extending support across model building, queries, updates, and compiled models.

Changes:

  • Adds owned-navigation configuration APIs and preserves complex metadata when owned types are rebuilt.
  • Extends relational query binding, JSON column naming, update handling, and validation.
  • Adds shared regression tests, provider SQL assertions, migration coverage, and compiled-model baselines.
File Description
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​TagComplexUnsafeAccessors.cs Generated tag field accessor.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnerWithComplexUnsafeAccessors.cs Generated owner field accessors.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnerWithComplexEntityType.cs Compiled owner metadata for SQL Server.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnedWithComplexUnsafeAccessors.cs Generated owned-type field accessors.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​LocationComplexUnsafeAccessors.cs Generated location field accessors.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextModelBuilder.cs Compiled relational and JSON mappings.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextModel.cs Compiled-model initialization baseline.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextAssemblyAttributes.cs Registers the SQL Server compiled model.
test/​EFCore.SqlServer.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​CoordinatesComplexUnsafeAccessors.cs Generated coordinate field accessors.
test/​EFCore.SqlServer.FunctionalTests/​Migrations/​MigrationsSqlServerTest.cs SQL Server table-creation assertions.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​TagComplexUnsafeAccessors.cs Generated tag field accessor.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnerWithComplexUnsafeAccessors.cs Generated owner field accessors.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnerWithComplexEntityType.cs Compiled owner metadata for SQLite.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​OwnedWithComplexUnsafeAccessors.cs Generated owned-type field accessors.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​LocationComplexUnsafeAccessors.cs Generated location field accessors.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextModelBuilder.cs Compiled relational and JSON mappings.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextModel.cs Compiled-model initialization baseline.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​DbContextAssemblyAttributes.cs Registers the SQLite compiled model.
test/​EFCore.Sqlite.FunctionalTests/​Scaffolding/​Baselines/​Complex_properties_on_owned_types/​CoordinatesComplexUnsafeAccessors.cs Generated coordinate field accessors.
test/​EFCore.Sqlite.FunctionalTests/​Migrations/​MigrationsSqliteTest.cs SQLite table-creation assertions.
test/​EFCore.Specification.Tests/​Query/​OwnedComplexPropertiesQueryTestBase.cs Shared query, update, and conversion tests.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.TestModel.cs Models for owned complex-type tests.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.OwnedTypes.cs Fluent and attribute-based configuration tests.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.NonGeneric.cs Non-generic test-builder adapters.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.Generic.cs Generic test-builder adapters.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.cs Shared complex configuration test contracts.
test/​EFCore.Specification.Tests/​ModelBuilding/​ModelBuilderTest.ComplexCollections.cs Complex collections on owned-type tests.
test/​EFCore.Relational.Tests/​Migrations/​Internal/​MigrationsModelDifferTest.cs Migration diffs for owned complex properties.
test/​EFCore.Relational.Tests/​Infrastructure/​RelationalModelValidatorTest.Json.cs Supported and rejected JSON mapping tests.
test/​EFCore.Relational.Specification.Tests/​Scaffolding/​CompiledModelRelationalTestBase.cs Compiled-model mapping and round-trip tests.
test/​EFCore.Relational.Specification.Tests/​Query/​OwnedComplexPropertiesQueryRelationalTestBase.cs Relational mapping, query, and JSON update tests.
test/​EFCore.Relational.Specification.Tests/​ModelBuilding/​RelationalModelBuilderTest.cs Default JSON column naming tests.
test/​EFCore.Relational.Specification.Tests/​Migrations/​MigrationsTestBase.cs Shared migration table-creation test.
test/​EFCore.Design.Tests/​Migrations/​Design/​CSharpMigrationsGeneratorTest.ModelSnapshot.cs Snapshot generation and round-trip coverage.
test/​EFCore.Cosmos.FunctionalTests/​Query/​OwnedComplexPropertiesQueryCosmosTest.cs Cosmos query baselines and converter limitation.
src/​EFCore/​Metadata/​Internal/​InternalEntityTypeBuilder.cs Detaches complex properties with owned metadata.
src/​EFCore/​Metadata/​Internal/​EntityType.cs Reattaches saved complex properties.
src/​EFCore/​Metadata/​Internal/​ComplexPropertySnapshot.cs Regenerates default names during reattachment.
src/​EFCore/​Metadata/​Internal/​ComplexProperty.cs Centralizes default complex-type naming.
src/​EFCore/​Metadata/​Builders/​OwnedNavigationBuilder.cs Adds complex-property and collection APIs.
src/​EFCore/​EFCore.baseline.json Records new owned-navigation APIs.
src/​EFCore.Relational/​Update/​ModificationCommand.cs Includes complex paths and guards JSON scalar patches.
src/​EFCore.Relational/​Query/​SqlExpressions/​SelectExpression.cs Binds and lifts owned complex projections.
src/​EFCore.Relational/​Query/​RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs Rejects updates inside JSON-owned complex members.
src/​EFCore.Relational/​Query/​RelationalQueryableMethodTranslatingExpressionVisitor.CreateSelect.cs Shares complex-property mapping helpers.
src/​EFCore.Relational/​Query/​JsonQueryExpression.cs Allows complex bindings on JSON-owned entities.
src/​EFCore.Relational/​Properties/​RelationalStrings.resx Adds the unsupported JSON collection diagnostic.
src/​EFCore.Relational/​Properties/​RelationalStrings.Designer.cs Generated accessor for the new diagnostic.
src/​EFCore.Relational/​Metadata/​Conventions/​RelationalMapToJsonConvention.cs Resolves default JSON names at finalization.
src/​EFCore.Relational/​Infrastructure/​RelationalModelValidator.cs Rejects complex properties within owned JSON collections.
src/​EFCore.Relational/​Extensions/​RelationalPropertyExtensions.cs Shares ownership-prefix calculation.
src/​EFCore.Relational/​Extensions/​RelationalComplexPropertyBuilderExtensions.cs Marks default JSON names for deferred prefixing.
src/​EFCore.Relational/​Extensions/​RelationalComplexCollectionBuilderExtensions.cs Applies deferred naming to complex collections.
src/​EFCore.Relational/​EFCore.Relational.baseline.json Records the new diagnostic API.

Review effort: Balanced

@jeremy-morren jeremy-morren changed the title Adds support for complex properties on owned types Support complex properties on owned types Nov 4, 2026
@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from 7b644a8 to 564a135 Compare November 4, 2026 16:07
Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active issues can corrupt configured JSON scalar representations on SQLite and overwrite an explicitly configured container name, causing the model to target the wrong database column.

2 open issues
3 resolved since last review
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from 564a135 to debc26d Compare November 4, 2026 16:51
Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Shared-type ownership transitions can lose or misbind complex-property keys, and SQLite scalar patches bypass configured JSON serialization, risking incorrect values or failures on subsequent loads.

3 open issues
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from debc26d to 6c062bc Compare November 4, 2026 17:39
Copilot AI balanced review requested due to automatic review settings November 4, 2026 17:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved complex-property path handling defects can break relationship reattachment, misconfigure nested owned members, and cause queries involving complex-property primary keys to throw.

6 open issues
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from 6c062bc to 6983f0c Compare November 4, 2026 18:02
Copilot AI balanced review requested due to automatic review settings November 4, 2026 18:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Relationship reattachment still misresolves complex principal-key paths during a nested-ownership shared-type transition, causing PropertyWrongEntityClrType and requiring a fix with regression coverage.

3 open issues
4 resolved since last review
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from 6983f0c to 5af17d9 Compare November 4, 2026 20:31
Copilot AI balanced review requested due to automatic review settings November 4, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The finalizer can overwrite an explicitly configured JSON container-column name with the ownership-prefixed default, silently changing migration and query targets; the marker must be cleared and both complex-property and complex-collection builder paths covered.

3 open issues
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@AndriySvyryd AndriySvyryd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also add some tests for precompiled queries.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 13:25
RelationalStructuralTypeShaperExpression.MakeNullable now also marks the
JsonQueryExpression of a JSON complex type as nullable, so scalars bound
from it over the optional side of a LEFT JOIN get IS NULL compensation
and unmatched rows are no longer dropped.
@jeremy-morren

jeremy-morren commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated as per feedback.

  • ToJson() without a name stores an empty container column name, which stands for the default. GetContainerColumnName() resolves it to the property name, unprefixed.
  • GetContainerColumnName(StoreObjectIdentifier) returns the column for that table or view. The default is prefixed with the ownership navigations when the owned type shares its owner's table (Owned_Address) and unprefixed when the owned type has its own table. The database column names are the same as before.
  • A name passed to ToJson(name) is always used as-is, even when it equals the property name.
  • Model snapshots emit .ToJson() for the default and .ToJson("name") for an explicit name, and compiled models store the empty name. This applies to every complex property, not only those on owned types.

Queries with a key declared on a complex type

This applies to any entity type, owned or not:

  • Distinct, set operations, and expanding an owned reference that has its own owned reference now translate. Previously threw Unable to bind 'property.<key>' to an entity projection.
  • Entity equality with a parameter and Contains over a local collection now compare the key through its complex property, including a key more than one complex property deep (Address.Country.Code). Previously threw InvalidCastException.

Set operations over a type with a JSON complex property

  • A non-collection JSON complex property can be filtered and projected after the set operation. Filtering on it failed with "could not be translated".

Fixed along the way:

  • Entity equality with a key on a complex type. Equality and Contains accessed the key property on the entity instead of through its complex property. A parameter or local collection threw InvalidCastException, and an entity with its own property of the same name was compared on the wrong property. The new association suite found this. It isn't specific to owned types: Entity_with_key_on_complex_property_equals_parameter and Entity_with_key_on_complex_property_in_local_collection fail without the fix on the existing Person model keyed on Id.Id.
  • Keys more than one complex property deep. Equality and Contains are also covered for HasKey("Address.Country.Code") by Owned_reference_with_key_on_nested_complex_property_equals_parameter and Owned_reference_with_key_on_nested_complex_property_in_local_collection.
  • Set operations rebuilt JSON complex references as collections. Also not specific to owned types: bug existed on main.
  • Nested owned reference under an owned type keyed on a complex member. A separate-table owned reference with HasKey("Address.Country.Code") and its own OwnsOne failed with Unable to bind 'property.Code'. Covered by Owned_reference_separate_table_with_key_on_complex_property_and_nested_owned_reference.

Gaps:

  • The InMemory provider still throws KeyNotFoundException for complex properties on owned types.
  • Cosmos SaveChanges coverage for complex properties on owned types was dropped with the old test classes.

As before, AI did most of heavy lifting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Explicit JSON column names matching property names are incorrectly prefixed for table-sharing owned navigations, causing queries to target the wrong column.

3 open issues
1 resolved since last review
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch 4 times, most recently from 55adf2f to 417940b Compare November 17, 2026 02:17
- Compute the ownership prefix in GetContainerColumnName(StoreObjectIdentifier) instead of RelationalMapToJsonConvention
- Store an empty container column name for ToJson() without a name, so explicit names are never prefixed
- Add Table/View.FindColumn(IComplexProperty)
- Add an OwnedComplexProperties suite under Query/Associations
- Move the remaining tests to existing test classes
- Add precompiled query tests
…et operations

- Bind key properties through the complex property chain in Distinct, set operations and owned navigation expansion
- Access the key through its complex properties in entity equality and Contains
- Keep non-collection JSON complex properties as references over set operations
- Don't use a key on a complex property as the ownership foreign key
- Patch scalars in non-null nullable complex properties of JSON owned references
@jeremy-morren
jeremy-morren force-pushed the complex-properties-on-owned-types branch from 417940b to 9fe8752 Compare November 17, 2026 14:07
@jeremy-morren

Copy link
Copy Markdown
Contributor Author

1 small note: this PR includes the commit and fix for #39524. Would you like me to close that PR, which will become irrelevant when this PR is merged?

@AndriySvyryd

Copy link
Copy Markdown
Member

1 small note: this PR includes the commit and fix for #39524. Would you like me to close that PR, which will become irrelevant when this PR is merged?

Yes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

ExecuteUpdate can target a nonexistent view-named JSON column when an owned reference uses different table and view prefixes; the setter and affected JSON references need rebinding to the target table column, with regression coverage.

3 open issues
1 resolved since last review
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-provider changes to persisted JSON paths, metadata reattachment, and query materialization require compatibility review and provider-backed functional and generated-code validation unavailable in this static review.

No open issues 🎉

3 resolved since last review
1 file not reviewed
  • src/EFCore.Relational/Properties/RelationalStrings.Designer.cs: Generated file

Review effort: Balanced

@AndriySvyryd AndriySvyryd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for your contribution!

@AndriySvyryd
AndriySvyryd merged commit 177ef9d into dotnet:main Nov 21, 2026
20 checks passed
@github-actions github-actions Bot added the api-review This PR or issue is introducing public API changes that need to be reviewed label Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API review baseline changes for src/EFCore.Relational/EFCore.Relational.baseline.json

Show diff

The diff below was generated by ApiChief between the base and the PR.

  static class Microsoft.EntityFrameworkCore.Diagnostics.RelationalStrings
+ static string ComplexPropertyInJsonOwnedCollection(object? complexProperty, object? entityType);

API review baseline changes for src/EFCore/EFCore.baseline.json

Show diff

The diff below was generated by ApiChief between the base and the PR.

  class Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder :
      Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder>
+ virtual ComplexCollectionBuilder ComplexCollection(Type propertyType, string propertyName);
+ virtual ComplexCollectionBuilder ComplexCollection(Type propertyType, string propertyName, string complexTypeName);
+ virtual ComplexCollectionBuilder ComplexCollection(string propertyName);
+ virtual OwnedNavigationBuilder ComplexCollection(Type propertyType, string propertyName, Action<ComplexCollectionBuilder> buildAction);
+ virtual OwnedNavigationBuilder ComplexCollection(Type propertyType, string propertyName, string complexTypeName,
+     Action<ComplexCollectionBuilder> buildAction);
+ virtual OwnedNavigationBuilder ComplexCollection(string propertyName, Action<ComplexCollectionBuilder> buildAction);
+ virtual ComplexPropertyBuilder ComplexProperty(Type propertyType, string propertyName);
+ virtual ComplexPropertyBuilder ComplexProperty(Type propertyType, string propertyName, string complexTypeName);
+ virtual ComplexPropertyBuilder ComplexProperty(string propertyName);
+ virtual OwnedNavigationBuilder ComplexProperty(Type propertyType, string propertyName, Action<ComplexPropertyBuilder> buildAction);
+ virtual OwnedNavigationBuilder ComplexProperty(Type propertyType, string propertyName, string complexTypeName, Action<ComplexPropertyBuilder> buildAction);
+ virtual OwnedNavigationBuilder ComplexProperty(string propertyName, Action<ComplexPropertyBuilder> buildAction);
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(string propertyName) where TProperty : notnull;
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(string propertyName, string complexTypeName) where TProperty : notnull;
+ virtual OwnedNavigationBuilder ComplexProperty<TProperty>(string propertyName,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual OwnedNavigationBuilder ComplexProperty<TProperty>(string propertyName, string complexTypeName,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TProperty,
+     TElement>(string propertyName) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TProperty, TElement>(string propertyName,
+     string complexTypeName) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;
+ virtual OwnedNavigationBuilder ComplexCollection<TProperty, TElement>(string propertyName,
+     Action<ComplexCollectionBuilder<TElement>> buildAction) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;
+ virtual OwnedNavigationBuilder ComplexCollection<TProperty, TElement>(string propertyName, string complexTypeName,
+     Action<ComplexCollectionBuilder<TElement>> buildAction) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;
  class
      Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.Code
      Analysis.DynamicallyAccessedMemberTypes.PublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicFields |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.Interfaces)] TOwnerEntity,
      [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicFields |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicFields |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicProperties |
      System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.Interfaces)] TDependentEntity> :
      Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder where TOwnerEntity : class where TDependentEntity : class
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection(Type propertyType, string propertyName,
+     Action<ComplexCollectionBuilder> buildAction);
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection(Type propertyType, string propertyName, string complexTypeName,
+     Action<ComplexCollectionBuilder> buildAction);
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection(string propertyName, Action<ComplexCollectionBuilder> buildAction);
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression) where TElement : notnull;
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression) where TElement : struct;
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TElement>(Expression<Func<TDependentEntity, IEnumerable<TElement?>?>> propertyExpression,
+     string complexTypeName) where TElement : notnull;
+ virtual ComplexCollectionBuilder<TElement> ComplexCollection<TElement>(Expression<Func<TDependentEntity, IEnumerable<TElement?>?>> propertyExpression,
+     string complexTypeName) where TElement : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression, Action<ComplexCollectionBuilder<TElement>> buildAction) where TElement : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression, Action<ComplexCollectionBuilder<TElement>> buildAction) where TElement : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression, string complexTypeName, Action<ComplexCollectionBuilder<TElement>> buildAction) where TElement : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TElement>(Expression<Func<TDependentEntity,
+     IEnumerable<TElement?>?>> propertyExpression, string complexTypeName, Action<ComplexCollectionBuilder<TElement>> buildAction) where TElement : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty(Type propertyType, string propertyName,
+     Action<ComplexPropertyBuilder> buildAction);
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty(Type propertyType, string propertyName, string complexTypeName,
+     Action<ComplexPropertyBuilder> buildAction);
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty(string propertyName, Action<ComplexPropertyBuilder> buildAction);
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(Expression<Func<TDependentEntity,
+     TProperty?>> propertyExpression) where TProperty : notnull;
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(Expression<Func<TDependentEntity,
+     TProperty?>> propertyExpression) where TProperty : struct;
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     string complexTypeName) where TProperty : notnull;
+ virtual ComplexPropertyBuilder<TProperty> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     string complexTypeName) where TProperty : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     string complexTypeName, Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(Expression<Func<TDependentEntity, TProperty?>> propertyExpression,
+     string complexTypeName, Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : struct;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(string propertyName,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexProperty<TProperty>(string propertyName, string complexTypeName,
+     Action<ComplexPropertyBuilder<TProperty>> buildAction) where TProperty : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TProperty, TElement>(string propertyName,
+     Action<ComplexCollectionBuilder<TElement>> buildAction) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;
+ virtual OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ComplexCollection<TProperty, TElement>(string propertyName, string complexTypeName,
+     Action<ComplexCollectionBuilder<TElement>> buildAction) where TProperty : System.Collections.Generic.IEnumerable<TElement> where TElement : notnull;

@jeremy-morren

Copy link
Copy Markdown
Contributor Author

No problem, thanks for your help reviewing it. I have a DB context with a huge number of owned types that could be complex types, so I'm keen to start using this when available.

@jeremy-morren
jeremy-morren deleted the complex-properties-on-owned-types branch November 21, 2026 02:07
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review This PR or issue is introducing public API changes that need to be reviewed community-contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter on JSON complex property over a LEFT JOIN drops unmatched rows Support complex properties on owned types

3 participants