I'm having a problem bulk inserting data using EF Extensions library by ZZZ Projects that the records should be unique for specific tables (lookup tables) and I'm importing files to the database so the records can be repeated, I can't find a way to make the library ignore existing data
I'm not sure which options to use when bulk inserting records that can exist multiple times.
You need the InsertIfNotExists option like below. The ColumnPrimaryKeyExpression is miss named. It can be any field in your data that you want unique.
await dbContext
.BulkInsertAsync(sourceFiles, options =>
{
options.BatchSize = BatchSize;
options.AutoMapOutputDirection = false;
options.InsertIfNotExists = true;
options.InsertKeepIdentity = false;
options.ColumnPrimaryKeyExpression = sf => new { sf.<YourUniqueField>};
})
.ConfigureAwait(false);