title: ADO EF Code First Bi-Directional Many-To-Many Self Reference Challenge
body: <p>I've been kicking the tyres on ADO EF Code First and have come up with the following issue:</p>
  
  <p>My model quite simply represents a family tree. 
  It consists of a Person Class with a few scalar properties FirstName etc and 
  a collection of Person representing Parents and 
  another collection of Person representing Children.</p>
  
  <pre><code>public class Person
  {
      public int id { get; set; }
      public string FirstName { get; set; }
      public string MiddleName { get; set; }
      public string LastName { get; set; }
      public DateTime? DateOfBirth { get; set; }
  
      List&lt;Person&gt; children = new List&lt;Person&gt;();
      public IList&lt;Person&gt; Children { get { return children; } set { children = (List&lt;Person&gt;)value; } }
  
      List&lt;Person&gt; parents = new List&lt;Person&gt;();
      public IList&lt;Person&gt; Parents { get { return parents; } set { parents = (List&lt;Person&gt;)value; } }
  }
  </code></pre>
  
  <p>The context code is quite simple</p>
  
  <pre><code>public class DataContext : DbContext
  {
      public DbSet&lt;Person&gt; People { get; set; }
  }
  </code></pre>
  
  <p>The DataBase schema that gets created is as expected.
  A People Table with 2 one-to-many relationships to a table named PersonPersons. (By the way, is there anyway to change this to a table named FamilyTree?)</p>
  
  <p>I then proceed to Seed the DataBase with some data, a family tree for the Popular Simpsons cartoon show.
  I create all the people I require, relate them and then save the person variable representing Homer Simpson.</p>
  
  <pre><code>class ProjectDBInitializer : DropCreateDatabaseIfModelChanges&lt;DataContext&gt;
  {
      protected override void Seed(DataContext context)
      {
          Person ph = new Person() { FirstName = "Homer", LastName = "Simpson" };
          Person pm = new Person() { FirstName = "Marge", LastName = "Simpson" };
  
          Person pb = new Person() { FirstName = "Bart", LastName = "Simpson" };
          Person pl = new Person() { FirstName = "Lisa", LastName = "Simpson" };
  
          Person phf = new Person() { FirstName = "GranPa", LastName = "Simpson" };
          Person phm = new Person() { FirstName = "GranMa", LastName = "Simpson" };
  
          Person pmf = new Person() { FirstName = "Marge Father", LastName = "Maiden" };
          Person pmm = new Person() { FirstName = "Marge Mother", LastName = "Maiden" };
  
          phf.Children.Add(ph);
          phm.Children.Add(ph);
  
          ph.Children.Add(pb);
          ph.Children.Add(pl);
  
          pb.Parents.Add(ph);
          pb.Parents.Add(pm);
  
          pl.Parents.Add(ph);
          pl.Parents.Add(pm);
  
          pm.Parents.Add(pmf);
          pm.Parents.Add(pmm);
  
          context.People.Add(ph);
          context.SaveChanges();
      }
  }
  </code></pre>
  
  <p>The problem comes into play when when I look at what's gone into the DataBase.</p>
  
  <p>All of Marge's Family have been inserted but Homer's parents (GranPa and GranMa) have not.
  I assume this has to do with the fact that the ph varibale has no reference to them even though they hold a reference to it in thier Children collection.</p>
  
  <p>What is the best (easiest) way of going about solving this problem?</p>