Add documentation for complex types - #5436
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new EF Core “Complex types” modeling article and supporting sample code, and then wires that documentation into the site navigation and various “What’s new” pages for cross-linking.
Changes:
- Added a new
core/modeling/complex-types.mddocumentation page and linked it from the main TOC. - Added a new runnable sample project under
samples/core/Modeling/ComplexTypesto back the article’s snippets. - Added “TIP” cross-links from EF Core 8–11 “What’s new” pages (and owned types docs) to the new complex types documentation.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| samples/global.json | Moves samples to .NET 11 preview SDK for building/running updated samples. |
| samples/core/Samples.sln | Adds the new ComplexTypes sample project and updates solution configurations. |
| samples/core/Modeling/ComplexTypes/Program.cs | Sample runner demonstrating saving, sharing instances, change tracking, and querying. |
| samples/core/Modeling/ComplexTypes/Model.cs | Sample model types used across the documentation snippets. |
| samples/core/Modeling/ComplexTypes/DataAnnotations.cs | Demonstrates [ComplexType] data annotation usage for complex types. |
| samples/core/Modeling/ComplexTypes/ComplexTypesContext.cs | Demonstrates Fluent API configuration, JSON mapping, indexing, and discriminator usage. |
| samples/core/Modeling/ComplexTypes/ComplexTypes.csproj | New sample project targeting net11.0 with EF Core 11 preview dependencies. |
| entity-framework/toc.yml | Adds the new Complex types page to the Modeling section. |
| entity-framework/core/what-is-new/ef-core-8.0/whatsnew.md | Adds a TIP pointing readers to the comprehensive Complex types docs. |
| entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md | Adds a TIP pointing readers to the comprehensive Complex types docs. |
| entity-framework/core/what-is-new/ef-core-10.0/whatsnew.md | Adds a TIP pointing readers to the comprehensive Complex types docs. |
| entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md | Adds a TIP pointing readers to the comprehensive Complex types docs. |
| entity-framework/core/modeling/owned-entities.md | Adds guidance pointing value-object scenarios toward complex types. |
| entity-framework/core/modeling/complex-types.md | New main documentation article for complex types (concepts, configuration, limitations, etc.). |
9ee3d07 to
c11d21c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
entity-framework/core/modeling/complex-types.md:35
- The comparison table says complex types have “Value semantics (properties are copied)”, but the very next row highlights that the same instance can be assigned to multiple properties. For reference-type complex types, “properties are copied” is misleading; it’s clearer to describe the semantics as “compared by value / reference identity is ignored”.
| Identity | Have a hidden key and identity | No identity; compared by value |
| Instance sharing | The same instance can't be referenced twice | The same instance can be assigned to multiple properties |
| Assignment semantics | Reference semantics | Value semantics (properties are copied) |
| .NET type | Reference types only | Reference _or_ value types |
entity-framework/core/modeling/complex-types.md:49
- Saying the assignment “simply copies the properties over” is misleading for the shown C# assignment (
customer.BillingAddress = customer.ShippingAddress;), which assigns the same instance for reference types. Consider rephrasing to focus on EF Core allowing the assignment (no identity conflict) and comparing by value, without implying automatic cloning.
Because complex types have value semantics, the same assignment simply copies the properties over, and works as expected. Similarly, comparing two complex values in a LINQ query compares their contents, whereas comparing two owned entities compares their identities.
</details>
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComplexTypes", "Modeling\ComplexTypes\ComplexTypes.csproj", "{114CFCD7-6755-4D74-BA81-E3C46D8FD4D8}" | ||
| EndProject |
| "sdk": { | ||
| "version": "10.0.100" | ||
| "version": "11.0.100-preview.6.26359.118", | ||
| "rollForward": "latestMinor" |
Fixes #4413