title: Having a List of the same object in Entity Framework
body: <p>I am designing a code-fire migration using Entity Framework and have some problem when one object has a List of the same type as itself. Say I have a <code>User</code> object which has a <code>List&lt;User&gt;</code> as its <code>Friends</code>:</p>
  
  <pre><code>public class User
  {
      [Key]
      public int UserId { get; set; }
  
      // some other stuff
  
      public List&lt;User&gt; Friends { get; set; }
  }
  </code></pre>
  
  <p>The problem is EF looks for a foreign key for the User and tries to create one when it couldn't find any: </p>
  
  <pre><code>AddColumn("dbo.Users", "User_UserId", c =&gt; c.Int());
  </code></pre>
  
  <p>I am trying to avoid making <code>UserId</code> a key and foreign key at the same time, so what's a good practice here?</p>