using System.Collections.Generic;
using System.Data.Entity;
using Z.EntityFramework.Classic;
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
this.Configuration.Audit.AutoSaveAction = (context, auditing) => {
foreach(var entry in auditing.EntriesXml)
Log.AppendLine("EntitySetName: " + entry.EntitySetName);
Log.AppendLine("EntityTypeName: " + entry.EntityTypeName);
Log.AppendLine("State: " + entry.State);
Log.AppendLine("StateName: " + entry.StateName);
Log.AppendLine("CreatedBy: " + entry.CreatedBy);
Log.AppendLine("CreatedDate: " + entry.CreatedDate);
Log.AppendLine("XmlProperties: " + entry.XmlProperties);
this.Configuration.Audit.IsEnabled = true;
public DbSet<Customer> Customers { get; set; }
public static StringBuilder Log = new StringBuilder();
public static void Main()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name = "Customer_A", Description = "Description" });
Console.WriteLine(Log.ToString());
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }