using System.Collections.Generic;
using System.Diagnostics;
using System.Data.Entity;
public static void Main()
var customers = GenerateCustomers(10);
using (var context = new EntityContext())
FiddleHelper.WriteTable("1 - Customers Before", context.Customers);
context.BulkInsert(customers, options => {
options.ColumnInputExpression = x => new { x.Code, x.CreatedDate };
FiddleHelper.WriteTable("2 - Customers After", context.Customers);
public static List<Customer> GenerateCustomers(int count)
var customers = new List<Customer>();
for(int i = 0; i < count; i++)
customers.Add(new Customer() { Code = "Inserted_" + i, Name = "Skipped_" + i, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now });
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? ModifiedDate { get; set; }