title: Mapping Entity Navigation Property to Same Table with Code First
body: <p>I have an entity with a Property called ParentId linked to an navigation property called Parent. This relationship seems to be working fine but my issue is now i want to have another navigation property which would be a list of "Child" items where the parent is the same as the entities ID.</p>
  
  <p>I have Tried "ID", "Parent" in my FK attribute but i get the "The ForeignKeyAttribute on property 'Children' on type 'jrSite.Core.SiteModel' is not valid" error.</p>
  
  <p>How do i tell EF that i want that navigation property to search the SiteModel table for items with matching parent id?</p>
  
  <p>My class is below</p>
  
  <pre><code>public class SiteModel
  {
      public SiteModel() { }
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public int ID { get; set; }
  
      public DateTime Created { get; set; }
  
      [ForeignKey("Creator")]
      public int CreatorID;
      public SiteAccount Creator { get; set; }
  
      [ForeignKey("Owner")]
      public int OwnerID;
      public SiteAccount Owner { get; set; }
  
      [ForeignKey("Parent")]
      public int? ParentID;
      public SiteModel Parent { get; set; }
  
      [ForeignKey("Parent")]
      public List&lt;SiteModel&gt; Children { get; set; }
  
      public SiteModel(SiteAccount creator, SiteAccount owner)
      {
          Creator = creator;
          Owner = owner;
          Created = DateTime.Now;
      }
  }
  </code></pre>