When mapping back from business logic objects to EF objects, one of the main problems I have is cases where the same instance has 2 parents:
(Objects are yellow, properties are orange)
In the business logic world, there is only one instance of the Tree object here (which appears as a child of multiple parents: Forest and Section)
When I map everything back into EF objects with AutoMapper, EF thinks there are 2 separate instances of tree (despite them having the same ID). It therefore creates a duplicate in the DB.
What is the correct way to manage this scenario so that both Forest and Section point to the same record of Tree in the DB?
Do we have to go through and manually make sure everything is attached which might be considered a duplicate?
