I am adding EF6 and trying to recreate a model of my old db. I am also creating a WCF web service. There are too many fields, so I minimized this example to better identify the problem.
I am trying to enter some data into the database for an order. An order includes OrderLines, and each OrderLine can be licensed. In rare cases, OrderLine is one of many, so I have to do it for many. If there is one OrderLine and License for the part, the next OrderLine and License for Maintenance for this part. The part license must refer to the service license.

Problem with ParentLicenceId. In my previous db, there is a relationship between one License and another License supporting PartType. Therefore, if a customer buys Part X, they can take 1 year of service for Part X. Thus, the service license for Part X will display the Part X license as its parent.
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<OrderLine>() };
In omc.SaveChanges (), an error message appears:
Unable to determine the primary end of the OrderExampleModel.LicenseParentLicense relationship. Multiple objects added can have the same primary key.
I tried:
I looked through several other articles. I hope that there are only some additional settings that I need to apply.
How do I get through this error to save these changes?
source share