using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public static void Main()
using (var context = new EntityContext())
var materialized = new List<object>();
((IObjectContextAdapter) context).ObjectContext.ObjectMaterialized += (sender, args) => materialized.Add(args.Entity);
var list = context.Customers.ToList();
FiddleHelper.WriteTable(materialized);
public static void GenerateCustomers()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Code = "Customer_A" });
context.Customers.Add(new Customer() { Code = "Customer_B" });
context.BatchSaveChanges();
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; }