using System.Data.Entity;
using System.Collections.Generic;
public static void Main()
var list = new List<Customer>()
new Customer () { Name = "Customer_A", Description = "Description_updated_1" },
new Customer () { Name = "Customer_A", Description = "Description_updated_2" },
new Customer() { Name ="Customer_B", Description = "Description"}
using (var context = new EntityContext())
context.BulkMerge(list,options =>
options.ColumnPrimaryKeyExpression = customer => customer.Name;
options.AllowDuplicateKeys = true;
FiddleHelper.WriteTable(context.Customers.ToList());
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name ="Customer_A", Description = "Description" });
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; }