using System.Data.Entity;
public static void Main()
using (var context = new EntityContext())
var count = context.Countries.DeferredCount().Cache();
Console.WriteLine("Countries Count: " + count);
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; }