KK.EntityFramework.Cache 1.3.4-alpha-1

This is a prerelease version of KK.EntityFramework.Cache.
dotnet add package KK.EntityFramework.Cache --version 1.3.4-alpha-1                
NuGet\Install-Package KK.EntityFramework.Cache -Version 1.3.4-alpha-1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KK.EntityFramework.Cache" Version="1.3.4-alpha-1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KK.EntityFramework.Cache --version 1.3.4-alpha-1                
#r "nuget: KK.EntityFramework.Cache, 1.3.4-alpha-1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install KK.EntityFramework.Cache as a Cake Addin
#addin nuget:?package=KK.EntityFramework.Cache&version=1.3.4-alpha-1&prerelease

// Install KK.EntityFramework.Cache as a Cake Tool
#tool nuget:?package=KK.EntityFramework.Cache&version=1.3.4-alpha-1&prerelease                

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.

This project was moved from https://efcache.codeplex.com

You may still find some useful information there:

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));
  }
}

Starting with version 1.1.1 you can also use the new static EntityFrameworkCache.Initialize() method to configure EF to use EFCache. The Initialize method should be invoked at app startup (before EF is used) - e.g. in the application static constructor. To initialize EFCache with the built-in InMemoryCache you can use the following code:

EntityFrameworkCache.Initialize(new InMemoryCache());

You can find more details in my blogpost

Disclaimer

I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Facebook)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.4-alpha-1 106 7/13/2023
1.3.4-alpha 89 7/13/2023