I have a simple requirement (so I thought...!)
I have a model that consists of Order, OrderLine, Product.
I want to create an Order and add OrderLines (each OrderLine related to a Product). I create the Order and add new OrderLines to it. Between posts I store the Order entity in Session (or ViewState). Just so you know I have added suppport for binary serialisation which works fine.
The relationship is therefore Order > OrderLine(s) > Product(s).
You might have already guessed what the problem is - that when I SaveChanges() I get the usual 'AcceptChanges cannot continue because the object’s key values conflict with another object in the ObjectStateManager.' error.
I have referred to a number of articles online but none seem to handle this case (where I have the relationship across more than two entities) e.g. http://blogs.msdn.com/b/diego/archive/2010/10/06/self-tracking-entities-applychanges-and-duplicate-entities.aspx.
This must be a very common requirement surely? Is there anyone out there doing the same kind of thing with Entity Framework (and without using DTOs etc)?
Cheers - help! :)
Nick