Thinktecture.EntityFrameworkCore icon indicating copy to clipboard operation
Thinktecture.EntityFrameworkCore copied to clipboard

Way to retrieve generated identity values for bulk inserted entities?

Open lqxdave opened this issue 3 years ago • 1 comments

With straight EF Core, calling MyDbContext.MyEntities.AddRange(someEntities) followed by MyDbContext.SaveChanges() results in someEntities having their Id column being populated with those generated by Sql Server; is there any way to accomplish the same with MyDbContext.BulkInsertAsync<MyEntity>()? Note that I am using version 2.0 of your library.

On an unrelated note, any plans to add Upsert functionality to 2.0, or is that only supported with EF 5.0?

lqxdave avatar May 07 '21 18:05 lqxdave

At the moment, BulkInsertAsync doesn't populate columns generated by the database. I may add support for that in the future, but not any time soon because my customers are generating Guids in .NET, so there is no real demand for this feature.

As for bulk-upsert, it is implemented in v3 already: documentation

PawelGerr avatar May 07 '21 19:05 PawelGerr