Second level Cache for Entity Framework 6.1

Source: Internet
Author: User

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 mo Del This is a sample provider does not work with Entity Framework 6 and newer. This are 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 are included in the project. To use the IT you need first configure EF using code based configuration. Here's an example of about 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));}  }

  


Before use:

Install the package:

After use:

Second level Cache for Entity Framework 6.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.