title: EFCore Many-To-Many relationship with the same table on the ends
body: <p>I want to track referrals for users. There are two entities classes.</p>
  
  <pre><code>public class User
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Email { get; set; }
      public string Phone { get; set; }
  
      public ICollection&lt;Referral&gt; Referrals { get; set; }
      public ICollection&lt;Referral&gt; Referrees { get; set; }
  }
  
  public class Referral
  {
      public long ReferrerId { get; set; }
      public long ReferreeId { get; set; }
  
      public virtual User Referrer { get; set; }
      public virtual User Referree { get; set; }
  }
  </code></pre>
  
  <p>I defined relationships between them through fluent API on model creating (for the Referral entity)</p>
  
  <pre><code>builder.HasOne(r =&gt; r.Referrer).WithMany(u =&gt; u.Referrals).HasForeignKey(r =&gt; r.ReferrerId);
  builder.HasOne(r =&gt; r.Referree).WithMany(u =&gt; u.Referrees).HasForeignKey(u =&gt; u.ReferreeId);
  </code></pre>
  
  <p>But when I try adding a migration, I get the </p>
  
  <blockquote>
    <p>Unable to determine the relationship represented by navigation
    property 'Referral.Referrer' of type 'User'. Either manually configure
    the relationship, or ignore this property using the '[NotMapped]'
    attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.</p>
  </blockquote>
  
  <p>error.</p>
  
  <p>What am I doing wrong?</p>