0

I am using EF6 (DB first) that connects to Oracle 11G.

I have an entity with child-entity (the PK in father is FK in child).

Now, I need to duplicate my entity along with its children.

In order to do so, I need to get an existing entity, detach it (using AsNoTracking() ), set a new ID to the entity, and set this new ID to the child entities too.

I am able to do it using an sequence and manually update the entity and the child entities.

I wonder if there is an easy way to do it?

Is there a way that I can update the ID in father entity, and the FK in the child will get updated automatically?

Thanks.

Nir
  • 601
  • 7
  • 21
  • You may want to have a look at [GraphDiff library](http://blog.brentmckendrick.com/introducing-graphdiff-for-entity-framework-code-first-allowing-automated-updates-of-a-graph-of-detached-entities/). – Fabjan Nov 29 '16 at 14:12
  • Possible duplicate: http://stackoverflow.com/q/14790012/861716. Or http://stackoverflow.com/q/36894190/861716 – Gert Arnold Nov 29 '16 at 14:13
  • I know that it possible to do it when using MSSQL, but Im connecting to Oracle. Also, Im using DB-first and not code-first – Nir Nov 29 '16 at 14:19
  • If the ID values are database-generated you can follow exactly the same procedure. – Gert Arnold Nov 29 '16 at 14:34

0 Answers0