title: Mapping lookup/junction table entity in many-to-many relationship
body: <p>I'm attempting to map a many-to-many relationship <strong>and</strong> include the lookup/junction table entity and I'm having some trouble.  Here are my (basic) models:</p>
  
  <pre><code>public class User
  {
      public int UserId { get; set; }
      public IList&lt;UserGroupCode&gt; Codes { get; set; }
  }
  
  public class Group
  {
      public int GroupId { get; set; }
      public IList&lt;UserGroupCode&gt; Codes { get; set; }
  }
  
  public class UserGroupCode
  {
      public int UserGroupCodeId { get; set; }
      public int UserId { get; set; }
      public int GroupId { get; set; }
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>Here is the configuration for <code>User</code> I've been working with</p>
  
  <pre><code>HasMany(p =&gt; p.Codes).WithMany().Map(m =&gt;
  {
      m.ToTable("UserGroupCodes");
      m.MapLeftKey("UserId");
      m.MapRightKey("UserGroupCodeId");
  });
  </code></pre>
  
  <p>I've seen a lot of articles on how to map many-to-many relationships which don't include the lookup table as an entity (the classic example is User-Roles relationships).  But, as you can see, I have a <code>Value</code> property on my <code>UserGroupCode</code> relationship which necessitates that relationship being an actual entity.</p>
  
  <p>Thanks in advance.</p>