title: Unable to determine the principal end of the relationship on saving Order - EF6
body: <p>I am adding EF6 and trying to recreate the model of my legacy db. I am also making a WCF web service. There are way too many fields, so I've minimized the example to better pinpoint the problem.</p>
  
  <p>I am trying to enter some data into the database for an Order. The Order includes OrderLines and each OrderLine can have licenses. OrderLine is one to many on rare occasions so I have to do one to many. If one OrderLine and License is for a part, the next OrderLine and License is for Maintenance for that part. The part license must link to the maintenance license.</p>
  
  <p><img src="https://i.stack.imgur.com/ljd3E.png" alt="enter image description here"></p>
  
  <p>ParentLicenceId is the issue. In my legacy db, there is the relationship between one License and another License that is of PartType Maintenance. So if a customer buys Part X, they might by 1 year of maintenance for Part X. So the Part X Maintenance License will list the Part X license as it's parent.</p>
  
  <pre><code>using OrderExample;
  using System;
  using System.Collections.Generic;
  
  namespace OrderExampleCmd
  {
      class Program
      {
          static void Main()
          {
              var omc = new OrderExampleEntities();
              var order = new Order
              {
                  OrderNumber = new Guid().ToString(),
                  OrderLines = new List&lt;OrderLine&gt;()
              };
              // Maitenance
              var orderLine1 = new OrderLine
              {
                  OrderLineNumber = 1,
                  Licenses = new List&lt;License&gt;()
              };
              var orderLine1License = new License
              {
                  LicenseType = "Maintenance"
              };
              orderLine1.Licenses.Add(orderLine1License);
  
              // Part
              var orderLine2 = new OrderLine
              {
                  OrderLineNumber = 2,
                  Licenses = new List&lt;License&gt;()
              };
              var orderLine2License = new License
              {
                  LicenseType = "Part",
                  MaintenanceLicense = orderLine1License
              };
              orderLine1License.PartLicenses.Add(orderLine2License);
  
              order.OrderLines.Add(orderLine1);
              order.OrderLines.Add(orderLine2);
  
              omc.Orders.Add(order);
              omc.SaveChanges();
          }
      }
  }
  </code></pre>
  
  <p>There error message occurs at omc.SaveChanges() and is this:</p>
  
  <p>Unable to determine the principal end of the 'OrderExampleModel.LicenseParentLicense' relationship. Multiple added entities may have the same primary key.</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/6041057/multiple-added-entities-may-have-the-same-primary-key">Multiple added entities may have the same primary key</a> but I am already using the object property and not the id property.</li>
  </ol>
  
  <p>I've gone through several other articles. I'm hoping there is just some advanced setting I need to apply.</p>
  
  <p>How do I get past this error to save these changes?</p>