title: EF Code First with many to many self referencing relationship
body: <p>I am starting out with using the EF Code First with MVC and am a bit stumped with something.  I have the following db structure (Sorry but I was not allowed to post an image unfortunately):  </p>
  
  <p>Table - Products<br>
  Table - RelatedProducts</p>
  
  <p>1-Many on Products.ProductID -> RelatedProducts.ProductID<br>
  1-Many on Products.ProductID -> RelatedProducts.RelatedProductID</p>
  
  <p>Basically I have a product that can have a series of products that are related to it.  These are kept in the RelatedProducts table with the relationship defined by the ProductID and the ProductID of the related product which I have named RelatedProductID.  In my code I has produced the following classes:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class MyDBEntities : DbContext
  {
      public DbSet&lt;Product&gt; Products { get; set; }
      public DbSet&lt;RelatedProduct&gt; RelatedProducts { get; set; }
  }
  
  public class Product
  {
      public Guid ProductID { get; set; }
      public string Name { get; set; }
      public string Heading { get; set; }
      public string Description { get; set; }
      public decimal Price { get; set; }
      public Guid CategoryID { get; set; }
      public string ImageURL { get; set; }
      public string LargeImageURL { get; set; }
      public string Serves { get; set; }
      public virtual List&lt;RelatedProduct&gt; RelatedProducts { get; set; }
  }
  public class RelatedProduct
  {
      public Guid ProductID { get; set; }
      public Guid RelatedProductID { get; set; }
      public virtual Product Product { get; set; }
      public virtual Product SimilarProduct { get; set; }
  }
  </code></pre>
  
  <p>I then try to access these in code using:</p>
  
  <pre class="lang-cs prettyprint-override"><code>myDB.Products.Include("RelatedProducts").Where(x =&gt; x.ProductID == productID).FirstOrDefault();
  </code></pre>
  
  <p>But I keep getting the following error:</p>
  
  <pre><code>{"Invalid column name 'ProductProductID2'.\r\nInvalid column name 'ProductProductID2'.\r\nInvalid column name 'ProductProductID'.\r\nInvalid column name 'ProductProductID1'.\r\nInvalid column name 'ProductProductID2'."}
  </code></pre>
  
  <p>What am I doing wrong?  I basically want to get a product then iterate through the RelatedProducts and display that product info.</p>