using System.Data.Entity;
using Z.EntityFramework.Classic;
public static void Main()
using (var context = new EntityContext())
FiddleHelper.WriteTable("After GenerateData", context.Customers.ToList());
using (var context = new EntityContext())
context.Configuration.SoftDelete.DisableTrigger<IEFSoftDelete>();
var list = context.Customers.Where(x => x.Name == "Customer_A").ToList();
context.Customers.RemoveRange(list);
FiddleHelper.WriteTable("After Delete With DisableTrigger", context.Customers.ToList());
context.Configuration.SoftDelete.EnableTrigger<IEFSoftDelete>();
context.Customers.RemoveRange(context.Customers.ToList());
using (var context = new EntityContext())
FiddleHelper.WriteTable("After Delete With EnableTrigger", context.Customers.ToList());
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Name = "Customer_A", Description = "Description" });
context.Customers.Add(new Customer() { Name = "Customer_B", Description = "Description" });
context.Customers.Add(new Customer() { Name = "Customer_C", Description = "Description" });
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public class Customer : IEFSoftDelete
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsDeleted { get; set; }