using System.Data.Entity;
using System.Runtime.Caching;
public static void Main()
using (var context = new EntityContext())
var options = new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromHours(2)};
var countries = context.Countries.Cache(options).ToList();
FiddleHelper.WriteTable(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; }