You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document complex type property configuration via lambda chaining
Add what's new section for dotnet/efcore#31236, showing how EF Core 11
allows configuring complex type properties directly via chained member
access (e.g. e => e.Details.Description) instead of requiring explicit
ComplexProperty().Property() calls.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,6 +83,37 @@ For more information on inheritance mapping strategies, see [Inheritance](xref:c
83
83
84
84
Complex types are now fully supported in the Azure Cosmos DB provider, embedded as nested JSON objects or arrays. For more information, [see the Cosmos DB section below](#cosmos-complex-types).
85
85
86
+
<aname="complex-types-property-chaining"></a>
87
+
88
+
### Configuring complex type properties via lambda chaining
89
+
90
+
Previously, configuring a property on a complex type required first calling `ComplexProperty` to get the complex type builder, and then calling `Property` on it:
91
+
92
+
```csharp
93
+
modelBuilder.Entity<MyEntity>()
94
+
.ComplexProperty(e=>e.Details)
95
+
.Property(d=>d.Description)
96
+
.HasMaxLength(500);
97
+
```
98
+
99
+
EF Core 11 now allows configuring complex type properties directly by chaining member access in the lambda expression passed to `Property`:
100
+
101
+
```csharp
102
+
modelBuilder.Entity<MyEntity>()
103
+
.Property(e=>e.Details.Description)
104
+
.HasMaxLength(500);
105
+
```
106
+
107
+
This also works with nested complex types:
108
+
109
+
```csharp
110
+
modelBuilder.Entity<MyEntity>()
111
+
.Property(e=>e.Details.Address.Street)
112
+
.HasMaxLength(200);
113
+
```
114
+
115
+
This simplifies model configuration by removing the need to explicitly navigate through intermediate complex type builders to reach the property you want to configure.
0 commit comments