title: Self referencing many to many relationships in Fluent NHibernate automapping automapping to 1:n and not n:n
body: <p>The title pretty much explains it all, I have a Member object that references 'Friends' who are also type Member.</p>
  
  <pre><code>public class Member : Entity
      {
          public Member()
          {            
              Friends = new List&lt;Member&gt;();
          }
  
          public virtual IList&lt;Member&gt; Friends
          {
              get; set;
          }
       }
  </code></pre>
  
  <p>The schema generation tool makes it a 1:n relationship while it should be a n:n relationship i.e. a column is added to the member table called member_id and no connecting table is created.</p>
  
  <p>Is there any way to make a Self referencing many to many relationships in Fluent NHibernate?</p>
  
  <p>I tried using an override that I got as an answer before:</p>
  
  <pre><code>public class MemberOverride : IAutoMappingOverride&lt;Member&gt;
  {
      public void Override(AutoMapping&lt;Member&gt; mapping)
      {
          mapping.HasManyToMany(m =&gt; m.Friends)
                 .Table("MemberFriendsLinkTable");
      }
  }
  </code></pre>
  
  <p>but I get the error message:</p>
  
  <p>"NHibernate.MappingException: Repeated column in mapping for collection: Proj.BO.Member.Friends column: Member_id"</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong> I found the answer, it's to put:</p>
  
  <pre><code>mapping.HasManyToMany(m =&gt; m.Friends).ParentKeyColumn("Member_Id").ChildKeyColumn("Friend_Id")
                     .Table("MemberFriendsLinkTable").Inverse().Cascade.SaveUpdate();
  </code></pre>