Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explanation and examples for conventions related to Owned -> Owner Navigational Properties #1628

Closed
douglasg14b opened this issue Aug 8, 2019 — with docs.microsoft.com · 1 comment · Fixed by #1906

Comments

Copy link

douglasg14b commented Aug 8, 2019

There seems to be a convention that a property matching the type of the Owner entity on the Owned entity will be automatically used as a navigation back to the owner.

This isn't documented, and presents challenges when trying to work around this.

Example:

Note: This is a crappy example that doesn't really convey a real-life use case, but does highlight the confusion from the conventions being unknown...

    public class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public RelatedPerson Related { get; set; }
    }

    [Owned]
    public class RelatedPerson
    {
        // Is this now a navigation property back to the owner, or is this a distinct Person separate from the owner?
        // What if this is supposed to not be a navigation property? How is that configured?
        public Person Person { get; set; }

        // If Person is a navigational property to the owner, is this Id set appropriately? If not?
        public int PersonId { get; set; }
    }

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@AndriySvyryd
Copy link
Member

@douglasg14b The convention is the same as for any other relationship, but I see why it's confusing for ownership.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants