Second Level Cache for Entity Framework 6.1

Second Level Cache for Entity Framework 6.1

Entity Framework does not currently support caching of query results. A sample EF Caching provider is available for Entity Framework version 5 and earlier but due to changes to the provider model this sample provider does not work with Entity Framework 6 and newer. This project is filling the gap by enabling caching of query results for Entity Framework 6.1 applications. https://efcache.codeplex.com/

How to get it

You can get it from NuGet - just install the EntityFramework.Cache NuGet package

How to use it

The project uses a combination of a wrapping provider and a transaction interceptor. A simple InMemoryCache is included in the project. To use it you need first configure EF using code based configuration. Here is an example of how such a configuration looks like.

public class Configuration : DbConfiguration
{
  public Configuration()
  {
    var transactionHandler = new CacheTransactionHandler(new InMemoryCache());

    AddInterceptor(transactionHandler);

    var cachingPolicy = new CachingPolicy();

    Loaded +=
      (sender, args) => args.ReplaceService<DbProviderServices>(
        (s, _) => new CachingProviderServices(s, transactionHandler,
          cachingPolicy));
  }
}

  

使用前:

安装package:

使用后:

时间: 2024-08-04 10:37:56

Second Level Cache for Entity Framework 6.1的相关文章

[转]Porting to Oracle with Entity Framework NLog

本文转自:http://izzydev.net/.net/oracle/entityframework/2017/02/01/Porting-to-Oracle-with-Entity-Framework.html We had to port our giant-_ish_, Entity Framework based application to work on Oracle RDBMS (11g, later 12c). We did it. And we learned a lot.

[转]Upgrading to Async with Entity Framework, MVC, OData AsyncEntitySetController, Kendo UI, Glimpse &amp; Generic Unit of Work Repository Framework v2.0

本文转自:http://www.tuicool.com/articles/BBVr6z Thanks to everyone for allowing us to give back to the .NET community, we released v1.0 of the Generic Unit of Work and Repository Framework for four weeks and received 655 downloads and 4121 views. This po

Solving the Detached Many-to-Many Problem with the Entity Framework

Introduction This article is part of the ongoing series I've been writing recently, but can be read as a standalone article.  I'm going to do a better job of integrating the changes documented here into the ongoing solution I've been building. Howeve

《Entity Framework 6 Recipes》翻译系列 (1) -----第一章 开始使用实体框架之历史和框架简述 (转)

微软的Entity Framework 受到越来越多人的关注和使用,Entity Framework7.0版本也即将发行.虽然已经开源,可遗憾的是,国内没有关于它的书籍,更不用说好书了,可能是因为EF版本更新太快,没人愿意去花时间翻译国外关于EF的书籍.使用Entity Framework开发已经有3年多了,但用得很肤浅,最近想深入学习,只好找来英文书<Entity Framework 6 Recipes>第二版,慢慢啃.首先需要说明的是,我英文不好,只是为了学习EF.把学习的过程写成博客,一

第一篇 Entity Framework Plus 之 Audit

一般系统会有登陆日志,操作日志,异常日志,已经满足大部分的需求了.但是有时候,还是需要Audit 审计日志,审计日志,主要针对数据增,改,删操作数据变化的记录,主要是对数据变化的一个追踪过程.其中主要追踪数据关键点如下 1. 新增 具体新增哪些数据,值是什么,新增人谁. 2. 修改 具体修改哪些数据,之前值是什么,修改后值是什么,修改人谁. 3. 删除 具体删除哪些数据,之前值是什么,删除人谁. 有了这个Audit追踪过程,当那天,用户操作的数据出现问题,你就可以根据这个Audit将数据恢复到某

Entity Framework 6 开发系列 目录

2014 年开始接触 Entity Framework 6 也快两年,用它已经沉淀了一个成熟架构,也用来开发了不少大大小小的产品和项目,直到这段时间,才真正有时间来回顾,重新学习它,为让大家更加了解Entity Framework 6,以及想把这两年中,开发过程中碰到的种种问题,跟大家分享,特此想做一个Entity Framework 6 开发系列的计划 第一篇:Entity Framework 简介 第二篇:Entity Framework CodeFirst & Model 映射 第三篇:E

Entity Framework 6 Code First创建

基本上我是DB先设计好的,所以就按现存在的table去写程式. 1.Web.config里配置Db连接字串,Connection String Name为DefaultConnection <connectionStrings> <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\

MVC5 Entity Framework学习之弹性连接和命令拦截

到目前为止,应用程序一直在本地IIS Express上运行.如果你想让别人通过互联网访问你的应用程序,你必须将它部署到WEB服务器同时将数据库部署到数据库服务器 本篇文章中将教你如何使用在将你的应用程序部署到云环境时的Entity Framework 6的非常有价值的两个特性:弹性连接(瞬时错误的自动重试)和命令拦截(捕获所有发送到数据库的SQL查询语句并记录至日志中). 1.启用弹性连接 当你将应用程序部署到Windows Azure时,相应的数据库部也应被部署到Windows Azure S

Entity Framework Plus 系列目录

Entity Framework Plus 系列文章计划的已经全部写完,可能还有其他功能没有写到,希望大家能够多动手,尝试一下使用,一定会给您带来一些帮助的.文章全部写完,也应该出一个目录方便查看,目录如下 第一篇 Entity Framework Plus 之 Audit 第二篇 Entity Framework Plus 之 Query Future 第三篇 Entity Framework Plus 之 Query Cache 第四篇 Entity Framework Plus 之 Bat