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

BulkInsertOrUpdate PK column does not get auto generated

Open sokunna opened this issue 1 year ago • 1 comments

I'm using this method to do insert if the data does not already exist otherwise update. However the PK Id column is always inserted as an empty guid. I'm using version 7.0.4.

My primary key has these attributes set: [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]

BulkConfig bulkConfig = new BulkConfig { UpdateByProperties = updateByProperties, PropertiesToExcludeOnUpdate = excludedProperties, PropertiesToExcludeOnCompare = excludeOnCompare, SetOutputIdentity = true, SqlBulkCopyOptions = SqlBulkCopyOptions.KeepIdentity }; await _dbContext.BulkInsertOrUpdateAsync(models, bulkConfig);

sokunna avatar Dec 01 '23 00:12 sokunna