using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using Microsoft.Data.SqlClient;
public static void Main()
using (var context = new EntityContext())
context.Database.EnsureCreated();
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name = "A" });
context.BulkSaveChanges();
using (var context = new EntityContext())
var customers = new List<Customer>();
customers.Add(new Customer() { CustomerID = 1, Name = "A_Updated" });
customers.Add(new Customer() { Name = "B" });
customers.Add(new Customer() { Name = "C" });
context.BulkMerge(customers);
FiddleHelper.WriteTable("1 - Customers", customers);
public class EntityContext : DbContext
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
optionsBuilder.UseSqlServer(new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()));
base.OnConfiguring(optionsBuilder);
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }