Parent Child Insert with BulkInsert

Jan 26, 2015 at 7:46 AM
Edited Jan 26, 2015 at 8:26 AM
I am now using the 6.0.2.8 version of EntityFramework.BulkInsert.

My database has a parent and child table respectively, similar to this:

Parent Table

ID (int, Primary key)
Name (nvarchar(255))

Child Table

ID (int, Primary key)
ParentID (int, reference to parent table)
Name (nvarchar (255))

Since I have lots of child objects to insert, I use BulkInsert.
  1. Create a new parent item and use the context to insert to the database (not by bulk). Get the parent ID as ParentIDA.
  2. Create lots of child item and fill their ParentID=ParentIDA. Call context.BulkInsert to them to the database.
  3. Refresh the context
  4. When I try to get the parent object, it has ZERO children only.
How can I get the correct parent (or "synchronize" the parent status) such that the parent can get the children correctly?

Thanks.
Apr 28, 2015 at 2:57 PM
Even I am looking for an answer for this.
May 2, 2015 at 2:17 AM
I'm looking for an answer to this question too.
Jun 11, 2015 at 10:25 PM
Bump

I feel like I shouldn't even have to do what you're describing, why can't bulk insert handle child collections?