c# - EF6 Updating 3 tables in one go -
i have database 3 tables table customer customerid (pk) name table order orderid (pk) customerid (fk) orderdate table orderdetailline orderdetaillineid orderid (fk) price productcode what in entity framework add 1 customer, add several different orders, each many orderdetailline relating first customer inserted. have hooked relationship in sql server , imported them ef model. no problems. can insert 1 customer , many orders , orderdetailline first time records inserted ok correct databse tables i looping around customer , orders in file adding adding customer , orders database but when want add order same customer( getting primary key violation on customer customerid). ef trying re-insert same customer after initial context.savechanges(); so, how stop ef trying add same customer when using same datacontext? i have been going around in circles hours , getting same error {"the insert statement conflicted foreign key constra...