This code represents in small scale my problem:
public class Person
{
public int ID { get; set; }
public string Name { get; set; }
public virtual Person Parent { get; set; }
public virtual ICollection<Person> Friends { get; set; }
}
When I use this class in an Entity Framework (4.1) scenario, the system generates one only relation, thinking that Parent and Friends are the two faces of the same relation.
How can I tell to semantically separate the properties, and generate two different relations in SQL Server (since we can see that Friends are totally different from Parents :-)).
I tried with the fluent interfaces, but I think I don’t know the right calls to do.
Thanks to all.
Andrea Bioli
You could use this in the Fluent API:
I am assuming here that the relationships are optional. The People table gets two foreign keys
FriendIDandParentIDnow. Something like this should work then: