I am playing with Entity Framework (code first) and want my model to reference itself... which is clearly explained in several places and it fairly straightforward:
public class Person{
public ICollection<Person> People { get; set; }
}
I want this relationship to work bi-directionally - I want to retrieve this relationship in a similar or identical manner regardless of which person in the relationship I'm querying for.
I also want to describe that relationship with a string.
I am not readily finding information on this sort of relationship. Perhaps there's a specific name for this kind of relationship I am unaware of. Based on other frameworks I've used, I would expect to build something sort of like:
public class Person{
public ICollection<PeoplePeople> RelatedPeople { get; set; }
}
public class PeoplePeople{
public Person personOne { get; set; }
public Person personTwo { get; set; }
public string Relationship { get; set; }
}
Is this the right way to go about this relationship in Entity Framework?
Other thoughts
Perhaps as an array of people?
public class PeoplePeople{
public Person[] people { get; set; }
public string Relationship { get; set; }
}
Not sure how EF would handle this in the DB though, might not be what is needed.