Right now EFUtilities can only insert into a single table in each call. That means that an entity with child entities would have to be inserted with two call.
This could be made easier. My question is how far I should take it. My personal feeling is that it's better to make an API that's simple and gives you control. Rember that these methods are there to insert really large number of items efficiently.
My thought is that it would require explicitly setting which child collections to insert.
The other alternative is for it to always insert the whole object graph automatically. Like the DbContext does today.
EFBatchOperation.For(db, db.BlogPosts).InsertAll(posts);
//Magic happens and everything is saved
So what does people prefer? Would you like to be able to control exactly what goes in or would you prefer the automagic solution?
Some notes:
This will work even with db generated id's. I found a solution to get the id's back even when using SqlBulkCopy.
That "setting" is more than for just includes. It supports some other parameters too and will be used for future options/enhancements. sSo even if it looks uglier it gives more flexibility. For example because different entities have different "byte size" the BatchSize should probably be configured differently for optimal performance.
Right now EFUtilities can only insert into a single table in each call. That means that an entity with child entities would have to be inserted with two call.
This could be made easier. My question is how far I should take it. My personal feeling is that it's better to make an API that's simple and gives you control. Rember that these methods are there to insert really large number of items efficiently.
My thought is that it would require explicitly setting which child collections to insert.
Or with nesting:
Or with EF7 style includes:
The other alternative is for it to always insert the whole object graph automatically. Like the DbContext does today.
So what does people prefer? Would you like to be able to control exactly what goes in or would you prefer the automagic solution?
Some notes: