-
Notifications
You must be signed in to change notification settings - Fork 2k
Documentation should include how to map many to many relationship with self-referencing relations #3810
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Please provide more details on this. Ideally, attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
Adding the link to Gist. |
@prashantchoudhary So are you attempting to use EF mappings to create a many-to-many relationship between Person and Person, using Friendship as the join table? Or are you attempting to create two one-to-many relationships to simulate a many-to-many--i.e. not using EF's many-to-many mapping support? Also, are you attempting to use the same FK and navigation for both directions of the many-to-many? (I'm trying to understand your code, but I'm finding it really difficult to understand the intention here.) |
I am trying to represent friendship, Where One person can have many Friendships. So it is Many to many relation, but not direct. Person--> HasMany -FriendShip So yes, it is many to many relations between Persons using Friendship as the Join table. |
In docs there are no examples of |
@prashantchoudhary I think the main issue here is that EF cannot re-use the same navigation property for multiple relationships. That being said, we will document the normal way to do self-referencing many-to-many relationships. |
Many to many relations don't work by default, if it is a reference between same entity. And implementing this is not trivial. So I believe the work around should be included in documentation.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: