title: Entity Framework many-to-many self-reference
body: <p>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:</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p>and the modelBuilder:</p>
  
  <pre><code>modelBuilder.Entity&lt;Employee&gt;().
        HasOptional(e =&gt; e.Manager).
        WithMany().
        HasForeignKey(m =&gt; m.ManagerID);
  </code></pre>
  
  <p>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)?</p>
  
  <p>Sorry if there already exists a similar thread. 
  Any help is greatly appreciated.</p>