I have an entity User. Each User is supposed to have many Friends and Teachers. With EF Code First I am a little bit confused on how to achieve what I want. I saw examples of self reference, but not many-to-many. For example:
public class Employee
{
#region Properties
public int EmployeeID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int? ManagerID { get; set; }
public Employee Manager { get; set; }
#endregion
}
and the modelBuilder:
modelBuilder.Entity<Employee>().
HasOptional(e => e.Manager).
WithMany().
HasForeignKey(m => m.ManagerID);
How to create an entity with self-reference in my case, where there are Friends (if a is friend with b this means that b is friend with a) and Teachers (if a is teacher of b, b is student of a)?
Sorry if there already exists a similar thread. Any help is greatly appreciated.