Updating data in two related tables using GraphDiff

c# entity-framework graphdiff

Question

My tables are Order and OrderItems.

The OrderId column is the primary key in the Order table. This column serves as a foreign key in the OrderItems as well.

If a given Order has two items and the OrderId is 1, the OrderItems table will include two rows, each of which has the OrderID set to 1.

I made a context for the two tables using EF.

Now, there is a Status column in both the Order and OrderItems tables.

I intended to change this value using GraphDiff as follows:

using (var ordersContext = new OrdersContext())
{
    ordersContext.UpdateGraph(orderToUpdate, map => map.OwnedCollection(p => p.OrderItems));
    ordersContext.SaveChanges();
}

The following exception results from this:

GraphDiff supports detached entities only at this time. Please try AsNoTracking() or detach your entites before calling the UpdateGraph method

Any hints?

I appreciate it.

1
3
11/5/2014 6:34:23 AM

Popular Answer

ZZZ_tmp
0
3/4/2015 3:37:40 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow