using System.Data.Entity;
public static int ApplicationTenantID = 1;
public static void Main()
using (var context = new EntityContext())
var list = context.Customers.ToList();
FiddleHelper.WriteTable("Customers", list);
public static void GenerateData()
using (var context = new EntityContext())
context.Customers.Add(new Customer() { TenantID = 1, Name = "Customer_A", Description = "Description" });
context.Customers.Add(new Customer() { TenantID = 1, Name = "Customer_B", Description = "Description" });
context.Customers.Add(new Customer() { TenantID = 2, Name = "Customer_C", Description = "Description" });
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
this.Configuration.QueryFilter.Filter<ITenant>(x => x.TenantID == ApplicationTenantID);
public DbSet<Customer> Customers { get; set; }
int TenantID { get; set; }
public class Customer : ITenant
public int CustomerID { get; set; }
public int TenantID { get; set; }
public string Name { get; set; }
public string Description { get; set; }