that northwind lookalike code probably fails because of the Orders' fields not being filled in
Sorry, I didn't provide all the code (I was just illustrating the intention), and it would be enough to add the following initialization:
order.CustomerId = "ALFKI";
order.EmployeeId = 1;
Entity A 1:n Entity B, and you do: myA.Bs.Add(myB);
myA is saved but it is assumed A has an autonumber PK but in the database, this isn't defined. So myA is saved, but has not a new value, as the sequence isn't set in the database.
If you're using Oracle or other sequence using database, the PK of A has to be set to a sequence in the designer before generating code.
I am using SQLServer 2000 with autonumber for Orders PK (OrderID). I tried saving just OrdersEntity (without saving it recursevly) and it got OrderID generated, but as soon as I set SaveEntity parameter recurse to true, I get the exception.
So, if I understood it well, it fails because it doesn't set generated OrderID to orderDetails object, but I don't know how can I set it differently.