using System.Data.Entity;
using Z.EntityFramework.Classic;
public static void Main()
using (var context = new EntityContext())
var countries = context.Countries.Cache(new string[] { "countries", "states" });
var count = context.Countries.DeferredCount().Cache(new string[] { "countries", "states", "stats" });
FiddleHelper.WriteTable(countries);
Console.WriteLine("Countries Count: " + count);
QueryCacheManager.ExpireTag("countries");
public static void GenerateData()
using (var context = new EntityContext())
context.Countries.Add(new Country() { Name ="Customer_A" });
context.Countries.Add(new Country() { Name ="Customer_B" });
context.Countries.Add(new Country() { Name ="Customer_C" });
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Country> Countries { get; set; }
public int CountryID { get; set; }
public string Name { get; set; }