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 = "Login2", Password = "Password2" },
new Customer() { Name ="Customer_C", Description = "Description", Login = "Login3", Password = "Password3" }};
using (var context = new EntityContext())
context.BulkMerge(list, options => options.ColumnPrimaryKeyExpression = customer => new { customer.Login, customer.Password });
FiddleHelper.WriteTable(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; }