using System.Collections.Generic;
using System.Data.Entity;
using System.Threading.Tasks;
public static void Main()
public static async Task MainAsync()
var customizeToSynchronize = new List<Customer>();
for(int i = 0; i < 2; i++)
customizeToSynchronize.Add(new Customer() { Code = "Code_" + i, FirstName = "Updated_FirstName_" + i, LastName = "Updated_LastName_" + i });
for(int i = 0; i < 2; i++)
customizeToSynchronize.Add(new Customer() { Code = "New_Code_" + i, FirstName = "New_FirstName_" + i, LastName = "New_LastName_" + i });
using (var context = new EntityContext())
FiddleHelper.WriteTable("1 - Customers Before", context.Customers.AsNoTracking());
await context.BulkSynchronizeAsync(customizeToSynchronize);
FiddleHelper.WriteTable("2 - Customers After", context.Customers.AsNoTracking());
public static List<Customer> GenerateCustomers(int count)
var list = new List<Customer>();
for(int i = 0; i < count; i++)
list.Add(new Customer() { Code = "Code_" + i, FirstName = "FirstName_" + i, LastName = "LastName_" + i });
using (var context = new EntityContext())
context.BulkInsert(list);
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 FirstName { get; set; }
public string LastName { get; set; }