EFCore.BulkExtensions icon indicating copy to clipboard operation
EFCore.BulkExtensions copied to clipboard

EFCore Bulkextension's BulkInsertAsync not setting the id (identity field)

Open AnandSonake opened this issue 2 years ago • 2 comments

EFCore Bulkextension's BulkInsertAsync not setting the id (identity field).

we are using EFCore.BulkExtensions version 6.3.3 and as per this link this issue is fixed in v5.3.7. Is it really fixed or am I missing anything here ? We are getting negative id in result variable the below code:

public async Task InsertAsync(List<User> users) { BulkConfig bulkCOnfig = new BulkConfig() {
SetOutputIdentity = true }; await this.BulkInsertAsync(users, bulkCOnfig);

 var result = users.FirstOrDefault().Id;

} But if I use BulkInsertOrUpdateAsync then I'm getting Ids all records except the last one, not sure why BulkInsertAsync not returning the ids.

AnandSonake avatar Oct 23 '23 12:10 AnandSonake

Is it possible to update the MERGE operation to make use of OUTPUT clause to return the IDs of records inserted using BulkInsertAsync or BulkInsert ?

Reference: https://stackoverflow.com/questions/77343372/efcore-bulkextensions-bulkinsertasync-not-setting-the-id-identity-field?noredirect=1#comment136354159_77343372

AnandSonake avatar Nov 02 '23 18:11 AnandSonake