N.EntityFrameworkCore.Extensions
N.EntityFrameworkCore.Extensions copied to clipboard
Bulk Insert - Trigger Enabled Option
Using SQL Server - If i need to bulk insert on table , which has triggers enabled , that should be fired as well.
`awaais78,
In order to call BulkInsert and call any triggers on it at the same time, you would use the following code: ` var dbContext = SetupDbContext(false);
var products = new List<ProductWithTrigger>();
for (int i = 1; i < 1000; i++)
{
products.Add(new ProductWithTrigger { Id = i.ToString(), Price = 1.57M, StatusString="InStock" });
}
int rowsInserted = dbContext.BulkInsert(products, options => {
options.AutoMapOutput = false;
options.BulkCopyOptions = SqlBulkCopyOptions.FireTriggers;
});
`