EntityFrameworkCore.NCache
5.3.800
dotnet add package EntityFrameworkCore.NCache --version 5.3.800
NuGet\Install-Package EntityFrameworkCore.NCache -Version 5.3.800
<PackageReference Include="EntityFrameworkCore.NCache" Version="5.3.800" />
<PackageVersion Include="EntityFrameworkCore.NCache" Version="5.3.800" />
<PackageReference Include="EntityFrameworkCore.NCache" />
paket add EntityFrameworkCore.NCache --version 5.3.800
#r "nuget: EntityFrameworkCore.NCache, 5.3.800"
#:package EntityFrameworkCore.NCache@5.3.800
#addin nuget:?package=EntityFrameworkCore.NCache&version=5.3.800
#tool nuget:?package=EntityFrameworkCore.NCache&version=5.3.800
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
Prerequisites
Before using this package, ensure you have:
- An application on .NET 8.0+ or .NET Framework 4.6.2+, using the Entity Framework Core version for its target:
- .NET 10.0+: Entity Framework Core 10.x
- .NET 8.0 / 9.0: Entity Framework Core 8.x
- .NET Framework 4.6.2+: Entity Framework Core 3.1.x
- 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
- Open your application's configuration file:
- .NET / ASP.NET Core:
appsettings.json - .NET Framework / ASP.NET:
app.configorweb.config
- .NET / ASP.NET Core:
- Add an entry for the cache you created on the NCache server, keyed by the cache's name. The
example uses
defaultCache; replace it with your cache's name. - Set
serverto one or more nodes of the cluster where that cache is running. Separate multiple nodes with commas.
appsettings.json
{
"ncache": {
"defaultCache": {
"server": "20.200.20.24,20.200.20.25",
"port": 9800
}
}
}
app.config / web.config
<configuration>
<configSections>
<section name="ncache" type="Alachisoft.NCache.Client.NCacheSection, Alachisoft.NCache.Client" />
</configSections>
<ncache>
<caches>
<add name="defaultCache" server="20.200.20.24,20.200.20.25" port="9800" />
</caches>
</ncache>
</configuration>
The cache name in the configuration must match the name you pass in code:
ICache cache = CacheManager.GetCache("defaultCache");
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 | 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 Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- Alachisoft.NCache.SDK (>= 5.3.800)
- FSharp.Core (>= 9.0.300)
- Microsoft.EntityFrameworkCore.Relational (>= 3.1.0 && < 4.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.4)
- System.Collections.Immutable (>= 10.0.10)
- System.Text.Json (>= 10.0.10)
-
net10.0
- Alachisoft.NCache.SDK (>= 5.3.800)
- FSharp.Core (>= 8.0.100)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0 && < 11.0.0)
-
net8.0
- Alachisoft.NCache.SDK (>= 5.3.800)
- FSharp.Core (>= 8.0.100)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.1 && < 9.0.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.800 | 0 | 10/21/2026 |
| 5.3.7 | 229 | 8/6/2026 |
| 5.3.6.1 | 994 | 10/10/2025 |
| 5.3.6 | 720 | 8/12/2025 |
| 5.3.5 | 690 | 5/30/2025 |
| 5.3.4 | 3,571 | 6/6/2024 |
| 5.3.3 | 3,554 | 2/1/2024 |
| 5.3.2.1 | 2,842 | 10/12/2023 |
| 5.3.2 | 2,191 | 9/27/2023 |
| 5.3.1 | 3,455 | 8/4/2023 |
| 5.3.0 | 20,697 | 4/12/2022 |
| 5.2.1 | 4,359 | 10/12/2021 |
| 5.2.0 | 8,649 | 3/25/2021 |
| 5.1.0 | 6,007 | 11/23/2020 |
| 5.0.4.1 | 5,108 | 11/4/2020 |
| 5.0.4 | 4,693 | 10/28/2020 |
| 5.0.3 | 27,913 | 6/15/2020 |
| 5.0.2 | 41,504 | 1/6/2020 |