using System.Data.Entity;
using System.Collections.Generic;
public static void Main()
var list = new List<Customer>()
{ new Customer () { Name = "Customer_B", Description = "Updated_B", Login = "Login5", Password = "Password2" },
new Customer() { Name ="Customer_C", Description = "Description", Login = "Login3", Password = "Password3" }};
using (var context = new EntityContext())
context.BulkSynchronize(list, options => options.ColumnPrimaryKeyExpression = customer => customer.Name);
FiddleHelper.WriteTable("Case 1 - Delete Customer_A; Update Customer_B; Insert Customer_C;",context.Customers.ToList());
list = new List<Customer>()
{new Customer () {Name = "1", Description = "Updated_C", Login = "Login3", Password = "Password3" },
new Customer () { Name = "2", Login = "Login4", Password = "Password4" }};
using (var context = new EntityContext())
context.BulkSynchronize(list, options => options.ColumnPrimaryKeyExpression = customer => new { customer.Login, customer.Password });
FiddleHelper.WriteTable("Case 1 - Delete Customer_B; Update Customer_C; Insert Login4;",context.Customers.ToList());
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name ="Customer_A", Description = "Description", Login = "Login1", Password = "Password1" });
context.Customers.Add(new Customer() { Name ="Customer_B", Description = "Description" , Login = "Login2", Password = "Password2" });
context.BulkSaveChanges();
using (var context = new EntityContext())
FiddleHelper.WriteTable(context.Customers.ToList());
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Login { get; set; }
public string Password { get; set; }