How to copy a row with his data linked in other tables (related ) and insert them as a new records in All Tables, with :
ASP.NET MVC / C# / Linq (Method syntax) / Entity Framework Code-First
For Example :
I have these tables =>
I want to copy the last line of the "Customer" table and add it in a new line of the database with a new ID, and at the same time copy all orders related in the table "Order" and duplicate them with "CustoemerID" of the new "Customer" with new ID's , and at the same time copy all orders lines in table "OrderLine" and duplicate them with the new "OrderID"
How to do it ?
Is there a brief code for doing this?
The blue color is the last row in the database, and the green color is the result of the code what i'm looking for, a duplicate copy of the customer and his related data
Primary keys : CustomerID & OrderID & OrderLineID = AUTO INCREMENT Field