Repository navigation
Own a type by convention only if it can be embedded (Fixes #65) - #123
Merged
Merged
Conversation
A type reached through a navigation was always embedded as an owned type, even when it belongs to a root's hierarchy or when entity types outside its owner's document reference it. That broke relationships and many-to-many join entities. A type is now owned by convention only if it is not top-level (no DbSet, no explicit configuration, not in a root's hierarchy) and nothing outside the owning document references it: - A type deriving from a root entity type is not owned. - A type that holds a collection of its would-be owner is not owned. - An owned type that an independent entity type navigates to, and that navigates back, becomes an independent entity type. - An owned type that holds a collection of an explicitly configured entity type, or the join entity type of a skip navigation, becomes independent. Explicit OwnsOne, [Owned] and Owned<T>() always win, and types embedded from more than one place are left alone. Spec fixtures no longer need DoNotOwnTypes; pins that now pass are removed and the failing-test inventory is updated. Persisted document shape changes for some models (BREAKING-CHANGES.md). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, order-independent derived types (#65) - Classify collections with EF's member classifier, so [NotMapped] and ignored members no longer count as collections or back-references. Detection is candidate-driven and uses a walk up the base-type chain, which takes the 300-root chained model from 238 s back to a few seconds. - A type that stops being embedded loses the shadow key it had as an owned type; without a key property of its own the model now fails with "requires a primary key". - A derived type joins its root's hierarchy whichever of the two is registered first. - Remove the dead "explicit root registered after its owned holder" rule. - Pin the two loose EF-X545 spec tests to their real failures, update BREAKING-CHANGES.md and failing-spec-tests.md, and add unit and functional tests for the stored document shape. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65.
What
A type reached through a navigation was owned (embedded) by convention even when something outside its owner's document referred to it. That broke relationships and many-to-many join entities. A type is now owned by convention only if it can be embedded:
DbSet, explicitEntity<T>()or explicit relationship configuration);Explicit
OwnsOne,[Owned]andOwned<T>()are never undone. Two owners embedding the same CLR type still give two separate owned types. Details and the decision are in the comment on #65.Commits
Own a type by convention only if it can be embedded: the rules above.Ownership by convention: honour [NotMapped], ...: review follow-up.[NotMapped]and ignored members don't count.Breaking changes
Documented in
BREAKING-CHANGES.md. Stored document shape changes for a type that is now a root: a sub-document becomes a document in its own collection (a derived type goes into its root's collection with a discriminator). A root type with no key property that previously built only because it had been owned now fails with "requires a primary key". An explicitOwnsOneor[Owned]keeps the old shape.Tests
MongoOwnedTypeDemotionTests) and 5 functional tests for the stored shape (OwnershipByConventionTests).docs/failing-spec-tests.mdcounts are refreshed.test-allon the rebased tip (bd3221da, onrelease@7447eaf8): EF8-EF11 in Default and NativeOnly, unit, functional and spec, 0 failures in all 24 project runs; encryption tests ran.🤖 Generated with Claude Code