I’m looking for a solution were I can copy an object with several levels of children, update the primary key (and foreign key of the children) and save it on the DB again. Just so I can have an exact copy of the whole object but with a new key.
I tried using ValueInjuecter and it does create a deep copy but I don’t know how to update the foreign keys of the children to make them point to the newly created object.
I also tried AutoMapper and something similar happens.
Does anyone know how I can get this done?
Just write manual code to do the copying. It'll probably take you 30 minutes or so. You can also try using .NET's cloning with a BinaryFormatter, but that won't help with your PK/FK issues.