EFCore.BulkExtensions
EFCore.BulkExtensions copied to clipboard
BulkInsertOrUpdate PK column does not get auto generated
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);