Closed youngaj closed 5 years ago
@tonysneed is there anything he do here with Trackable?
Detaching entities is an EF Core feature, and the default behavior is non-recursive, meaning they are detached one at a time. If you want to detach all the entities that are being tracked by EF, you will need to do this yourself from within your service. See this SO answer for an example.
Closing for now. Please re-open if needed.
Is there a way to create a
Detached
TrackingState?I'm running into a problem where I want to detach a graph of objects but the service/repo seems to only detach the top level entity. When I go to save the entity it complains that another entity with the same id already exists but it should be part of the detached object graph.
My reason for doing this (and perhaps there is a better way, which I'm very open to) is that I want to track/record the changes to certain fields of my entity into another table (ChangeHistory). In order to do that in my API controller I do the following.
The
Parse
function creates a copy of the original with thedto
information overlain but does not overwrite the original to be used later as in a comparison.If I could mark each entity in
original
as not tracked or Detached then I could avoid the error.