title: How to map double related objects in entity framework, i.e. defining two FKs between the same entities
body: <p>I have table <code>User</code> and one more table <code>ProfileView</code>.<br/>
  They are in one to many relation.<br/>
  I have a problem to create a reference between those tables via code first.<br/>
  PageView looks like this:</p>
  
  <pre><code>public class ProfileView
      {
          public int ProfileViewId { get; set; }
          public int ViewedWho { get; set; }
          public virtual ApplicationUser ViewedWhoUser { get; set; }
          public DateTime ViewDate{get;set;}
          public int ViewedBy { get; set; }
          public virtual ApplicationUser ViewedByUser { get; set; }
      }
  </code></pre>
  
  <p>As you can see there are two references from <code>User</code> to <code>ProfileView</code> how can I map this objects?<br/>
  Right now EF auto gerate some keys with underscore not the one I created in boject.
  <br/><br/>
  Additionaly when I creating related object do I actually need to have something like <code>ICollection&lt;ProfileView&gt; ...</code> in related <code>User</code> object?<br/>
  I have tried to map it like this:</p>
  
  <pre><code>modelBuilder.Entity&lt;ApplicationUser&gt;()
                  .HasMany(m =&gt; m.WhoViewedMyProfile)
                  .WithMany(m =&gt; m.WhosProfileIViewed)
                  .Map(x =&gt; x.MapLeftKey("UserId")
                      .MapRightKey("ViewedWho")
                      .ToTable("ViewedBy"));
  </code></pre>
  
  <p>But all I get is this:<br/>
  <img src="https://i.stack.imgur.com/Jf8uP.png" alt="enter image description here">
  <br/>ApplicationUser.cs has:</p>
  
  <pre><code>public ICollection&lt;ApplicationUser&gt; WhoViewedMyProfile { get; set; }
          public ICollection&lt;ApplicationUser&gt; WhosProfileIViewed { get; set; }
  </code></pre>