using System.Collections.Generic;
using System.Data.Entity;
public static void Main()
var customers = new List<Customer>();
customers.Add(new Customer() { Name = "Carson", Type = 1, Description = "Updated_Description of Carson", IsActive = false });
customers.Add(new Customer() { Name = "Alexander", Type = 1, Description = "Description of Alexander", IsActive = false });
using (var context = new EntityContext())
context.BulkSynchronize(customers, options => {
options.ColumnPrimaryKeyExpression = customer => customer.Name;
options.ColumnSynchronizeDeleteKeySubsetExpression = customer => customer.Type;
FiddleHelper.WriteTable("Update Customer_A; Remove Customer_B; Do nothing Customer_C; Insert Customer_D",context.Customers.ToList());
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name = "Carson", Type = 1, Description = "Description of Carson", IsActive = true });
context.Customers.Add(new Customer() { Name = "Meredith", Type = 1, Description = "Description of Meredith", IsActive = true });
context.Customers.Add(new Customer() { Name = "Arturo", Type = 2, Description = "Description of Arturo", IsActive = true });
context.BulkSaveChanges();
FiddleHelper.WriteTable("Before BulkSynchronize",context.Customers.ToList());
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public int Type { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Boolean IsActive { get; set; }