EntityFrameworkCore.NCache
5.3.7
dotnet add package EntityFrameworkCore.NCache --version 5.3.7
NuGet\Install-Package EntityFrameworkCore.NCache -Version 5.3.7
<PackageReference Include="EntityFrameworkCore.NCache" Version="5.3.7" />
<PackageVersion Include="EntityFrameworkCore.NCache" Version="5.3.7" />
<PackageReference Include="EntityFrameworkCore.NCache" />
paket add EntityFrameworkCore.NCache --version 5.3.7
#r "nuget: EntityFrameworkCore.NCache, 5.3.7"
#:package EntityFrameworkCore.NCache@5.3.7
#addin nuget:?package=EntityFrameworkCore.NCache&version=5.3.7
#tool nuget:?package=EntityFrameworkCore.NCache&version=5.3.7
NCache Entity Framework Core
NCache Entity Framework Core integration extends Entity Framework Core with distributed query caching capabilities, allowing applications to cache query results in NCache using LINQ extension methods. It supports both transactional data and reference data caching while reducing database load and improving application performance.
The package provides synchronous and asynchronous extension methods that integrate directly with IQueryable, enabling applications to cache query results without modifying existing LINQ queries.
Key benefits:
- Distributed query caching for Entity Framework Core
- Synchronous and asynchronous query caching APIs
- Supports both transactional and reference data caching
- Flexible caching strategies for storing query results
- Reduces repetitive database queries and improves application scalability
Installation
Install-Package EntityFrameworkCore.NCache
or, using the .NET CLI:
dotnet add package EntityFrameworkCore.NCache
What is Installed
Installing this package adds the following NCache configuration files to your project:
- client.ncconf � Defines the cache client settings, including the cache name and the list of server nodes the client connects to.
- config.ncconf � Contains the cache configuration (cache topology, partitions, eviction policy, etc.) used when the cache is created or registered.
- tls.ncconf � Contains TLS/SSL settings used to secure communication between the client and the NCache cluster, if enabled.
Prerequisites
Before using this package, ensure you have:
- A running NCache Server cluster.
- An NCache cache created and running on the cluster.
- The EntityFrameworkCore.NCache package installed.
- Include the following namespaces in your application:
Alachisoft.NCache.EntityFrameworkCoreAlachisoft.NCache.Runtime.Caching
- Ensure the entities being cached are serializable.
Getting Started
Setting up NCache
If NCache is not installed on the machine running your application, update the configuration files included with this package so the client can connect to your cache.
- Open
client.ncconf. - Locate the cache entry named
myCacheand replace it with the name of your cache. - Update the server address to point to a node hosting that cache.
Example:
<cache id="myCache" ... >
<server name="10.0.0.1" ... />
</cache>
Replace:
myCachewith the name of your cache.10.0.0.1with the hostname or IP address of an NCache server node.
Configuration
Caching behavior is configured through the CachingOptions class, which controls how query results are stored in NCache.
| Property | Description |
|---|---|
QueryIdentifier |
Specifies a custom identifier for the cached query. If omitted, NCache automatically generates one based on the LINQ query. |
StoreAs.Collection |
Stores the complete query result as a single cache entry. |
StoreAs.SeparateEntities |
Stores each entity individually using separate cache keys, enabling fine-grained cache updates. |
bulkInsertChunkSize |
When using StoreAs.SeparateEntities, controls the number of entities inserted per bulk operation. Defaults to 1000. |
errorEnabled |
When true, cache-related failures are propagated as exceptions. Defaults to false. |
Query Caching APIs
NCache provides the following Entity Framework Core extension methods.
| Synchronous | Asynchronous |
|---|---|
FromCache |
FromCacheAsync |
FromCache and FromCacheAsync provide identical caching behavior. Use FromCacheAsync for asynchronous query execution.
FromCache
FromCache configures an Entity Framework Core query to use NCache. When the query is executed for the first time, the results are retrieved from the database and stored in the cache. Subsequent executions of the same query retrieve the results directly from NCache, reducing database round-trips.
This API is recommended for transactional data, where database updates occur frequently but repeated reads can benefit from caching.
Query Caching
NCache supports two strategies for storing Entity Framework Core query results:
- Collection � stores the complete query result as a single cache entry. This strategy is recommended for read-heavy scenarios where the entire result set is typically accessed together.
- SeparateEntities � stores each entity individually, allowing finer-grained cache updates and lookups.
For large datasets using StoreAs.SeparateEntities, bulk insertion can be optimized by configuring bulkInsertChunkSize, allowing entities to be cached in manageable chunks while avoiding connection timeouts.
References
Reference documentation is available at:
https://www.alachisoft.com/resources/docs/ncache/prog-guide/entity-framework-core-caching.html
Resources
- NCache Documentation
- NCache Entity Framework Core Documentation
- Alachisoft Website
- Sample Application
Technical Support
Alachisoft© provides various sources of technical support.
- Please refer to https://www.alachisoft.com/support.html to select a support resource suitable for your issue.
- To request additional features or report documentation issues, email support@alachisoft.com.
Copyright
Copyright � 2026 Alachisoft.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. 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 | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Alachisoft.NCache.SDK (>= 5.3.7.2)
- FSharp.Core (>= 9.0.300)
- Microsoft.Data.SqlClient (>= 6.1.1)
- Microsoft.EntityFrameworkCore.Relational (>= 3.1.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.4)
- Remotion.Linq (>= 2.2.0)
- System.Linq.Expressions (>= 4.3.0)
-
net6.0
- Alachisoft.NCache.SDK (>= 5.3.7.2)
- FSharp.Core (>= 6.0.3)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.2)
- Microsoft.Extensions.Caching.Memory (>= 9.0.4)
- Remotion.Linq (>= 2.2.0)
- System.Linq.Expressions (>= 4.3.0)
-
net8.0
- Alachisoft.NCache.SDK (>= 5.3.7.2)
- FSharp.Core (>= 8.0.100)
- Microsoft.Data.SqlClient (>= 6.1.1)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.1)
- Microsoft.Extensions.Caching.Memory (>= 9.0.4)
- Remotion.Linq (>= 2.2.0)
- System.Linq.Expressions (>= 4.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EntityFrameworkCore.NCache:
| Package | Downloads |
|---|---|
|
SahfieiSampleTest
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.3.7 | 47 | 8/6/2026 |
| 5.3.6.1 | 902 | 10/10/2025 |
| 5.3.6 | 521 | 8/12/2025 |
| 5.3.5 | 651 | 5/30/2025 |
| 5.3.4 | 3,465 | 6/6/2024 |
| 5.3.3 | 3,523 | 2/1/2024 |
| 5.3.2.1 | 2,815 | 10/12/2023 |
| 5.3.2 | 2,163 | 9/27/2023 |
| 5.3.1 | 3,438 | 8/4/2023 |
| 5.3.0 | 19,250 | 4/12/2022 |
| 5.2.1 | 4,339 | 10/12/2021 |
| 5.2.0 | 8,630 | 3/25/2021 |
| 5.1.0 | 5,977 | 11/23/2020 |
| 5.0.4.1 | 5,090 | 11/4/2020 |
| 5.0.4 | 4,668 | 10/28/2020 |
| 5.0.3 | 27,884 | 6/15/2020 |
| 5.0.2 | 41,488 | 1/6/2020 |