Entity Framework Cache Library

Introduction

Entity Framework Cache library allow you to cache the result of a LINQ query, usually in the memory, and re-use the cached result for subsequent calls.

Why using Cache with Entity Framework?

Common scenario:

  • Cache read-only table like countries and states
  • Cache rarely modified table (most libraries allow cache expiration)
  • Cache information related to the user logged


Google – Related Searches


Stack Overflow – Related Questions


Example

// using Z.EntityFramework.Plus; // Don't forget to include this.
var ctx = new EntitiesContext();
// The first call perform a database round trip
var countries1 = ctx.Countries.FromCache().ToList();
// Subsequent calls will take the value from the memory instead
var countries2 = ctx.Countries.FromCache().ToList();

Supported Library

Library Type EF Version Support Doc Features
Z.EntityFramework.Plus FREE EF5
EF6
EF Core
< 1 Day Yes
  • Audit
  • Batch Delete
  • Batch Update
  • Cache
  • Deferred Query
  • Filter
  • Future
  • Include Filter
  • Include Optimized
EntityFramework.Cache FREE EF6 < 2 Days No
  • Cache

Unsuported Library

Use them at your risk!

Library Type EF Version Support Doc Features
EntityFramework.Extended FREE EF5
EF6
No Yes
  • Audit
  • Batch Delete
  • Batch Update
  • Cache
  • Future