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.IsEnabled = false;
var list = context.Customers.Where(x => x.Name == "Customer_A").ToList();
context.Customers.RemoveRange(list);
FiddleHelper.WriteTable("After Delete With SoftDelete.IsEnabled = False", context.Customers.ToList());
context.Configuration.SoftDelete.IsEnabled = true;
context.Customers.RemoveRange(context.Customers.ToList());
using (var context = new EntityContext())
FiddleHelper.WriteTable("After Delete With SoftDelete.IsEnabled = True", 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; }