using System.Data.Entity;
public static void Main()
using (var context = new EntityContext())
context.Configuration.SoftDelete.GetTrigger<ICustomSoftDelete>().Disable();
var list = context.Customers.ToList();
context.Customers.RemoveRange(list);
using (var context = new EntityContext())
if (context.Customers.ToList().Count > 0)
FiddleHelper.WriteTable("Customers", context.Customers.ToList());
Console.WriteLine("No Customer in the database");
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())
this.Configuration.SoftDelete.Trigger<ICustomSoftDelete>((context, delete) =>{delete.IsActive = false; delete.DeletedAt = DateTime.UtcNow;});
public DbSet<Customer> Customers { get; set; }
public class Customer : ICustomSoftDelete
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
public DateTime? DeletedAt { get; set; }
public interface ICustomSoftDelete
bool IsActive { get; set; }
DateTime? DeletedAt { get; set; }