using System.Collections.Generic;
using System.Data.Entity;
public static void Main()
public static void Execute()
using (var context = new EntityContext())
var list = context.Customers.ToList();
list.ForEach(c => { c.Name += "_Updated"; c.Description += "_Updated"; });
list.Add(new Customer() { Name = "Customer_C_Inserted", Description = "Description_Customer_C_Inserted", IsActive = false });
var sb = new StringBuilder();
context.BulkMerge(list, options =>
options.UseLogDump = true;
Console.WriteLine(sb.ToString());
public static void SeedDatabase()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name ="Customer_A", Description = "Description_Customer_A", IsActive = false });
context.Customers.Add(new Customer() { Name ="Customer_B", Description = "Description_Customer_B", IsActive = false });
context.BulkSaveChanges();
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 Boolean IsActive { get; set; }