dotnet / dotnet/EntityFramework.Docs

I believe it's worth mentioning EF is capable of detecting replacements of owned entities.

Open
#4,981 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

### Type of issue

Missing information

### Description

If an instance of an owned entity is replaced with a new instance that has the same primary key, EF will detect the replacement and issue an update.

In contrast, if this were a regular navigation property, EF would raise an error, indicating an attempt to track multiple entities with the same identifier.

This highlights a significant difference in behavior between HasOne/HasMany and OwnsOne/OwnsMany.

### Page URL

https://learn.microsoft.com/en-us/ef/core/modeling/owned-entities

### Content source URL

https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/modeling/owned-entities.md

### Document Version Independent Id

e3effbd0-07f2-423d-4032-1722e75adb37

### Article author

@AndriySvyryd

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.