title: Entity framework code first many to many
body: <p>I've searched everyhwere but couldn't find an answer...</p>
  
  <p>First, I have created a many to many relationship using code first which worked well. Each person can be in multiple clubs and each club can have multiple members. The <code>ClubPersons</code> table has been created in the DB.</p>
  
  <pre><code>public class Person
  {
      public int PersonId { get; set; }
      public virtual ICollection&lt;Club&gt; Clubs { get; set; }
  }
  
  public class Club
  {
      public int ClubId { get; set; }
      public virtual ICollection&lt;Person&gt; Members { get; set; }
  }
  </code></pre>
  
  <p>Then I need to add the creator of the club which is also a person (one to many):</p>
  
  <pre><code>public class Club
  {
      public int ClubId { get; set; }
      public virtual ICollection&lt;Person&gt; Members { get; set; }
      public virtual Person Creator { get; set; }
  }
  </code></pre>
  
  <p>After doing this, the <code>ClubPersons</code> table in the DB has gone, replaced by a <code>Club_Id</code> in the <code>People</code> table and <code>Person_Id</code> and <code>Creator_Id</code> in the <code>Clubs</code> table.</p>
  
  <p>As you can see, this won't work and it gives me the following error when I try to add person/club:</p>
  
  <pre><code>Multiplicity constraint violated. The role 'Person_Clubs_Source' of the relationship 'Test.Models.Person_Clubs' has multiplicity 1 or 0..1.
  </code></pre>
  
  <p>My question is what's the proper way to define such relationship in code first? Many to Many to One</p>
  
  <p>Many thanks</p>