The Entity Framework is a set of technologies in ADO.NET that support the development of data-oriented software applications. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code than in traditional applications.
NCache introduces the caching provider which acts between Entity Framework and the Data source. The major reason behind the EF Caching provider is to reduce database trips (which slow down application performance) and serve the query result from the cache. The provider acts in between the ADO.NET entity framework and the original data source. Therefore caching provider can be plugged without changing/compiling the current code.
NCache Entity Framework Caching provider works under two modes. It can either be in "Caching" or in "Analysis" mode. In caching mode you can cache result-set of selected queries or you can have a CacheAll option where result of all SELECT queries will be cached automatically. Analysis mode works in pass-through mode and helps you find the queries that you should cache by generating a report showing which queries are being called with what frequency. For more help on Integration Modes
NCache Entity Framework provider also ensures that data in cache is always synchronized with the database. Therefore NCache uses .NET SqlCacheDependeny which registers a SQL query with SQL Server so if any row in the dataset represented by this query is changed in the database, SQL Server throws an event notification to NCache. NCache then removes the corresponding result-set from the cache.
1. You should have an Entity Framework application. (you can also use sample application for EFCaching from NCache sample applications from the following path:"Installeddirectory:/ProgramFiles/NCache/samples/clr20/EntityDataModelIntegrationDemo"
In every Entity Framework application, ADO.NET Entity Data Model is already added which automatically generates two files:
2. Microsoft Visual Studio 2008 with SP1.
3. Database Tool (e.g. MS SQL SERVER 2005, ORACLE)
Add "Alachisoft.Integrations.EntityFramework.CachingProvider" reference to your Entity Framework application. This .dll file is placed on the following path: "Installeddirectory:/ProgramFiles/NCache/integration/MSEntityFramework". After adding the reference, changes are required in 3 different files:
In SSDL file which is generated on adding ADO.NET Entity Data Model in Entity Framework application, required following changes:
[Below is the Sample change for Sql 2005 database]
In SSDL, the provider name is specified in the Provider attribute of the <Schema/> element as shown below:
In order to inject our NCache Entity frame Provider, we need to override the above highlighted attributes to plugin our provider. In SSDL, we put the name of the new provider in the Provider attribute and concatenate the previous provider with our provider manifest token in the ProviderManifestToken field, as shown below:
Application (or web) configuration file which is generated on adding ADO.NET Entity Data Model in Entity Framework application, required following changes:
Change provider name for our NCache Entity framework Provider and add provider wrapper information in provider connection string:
NOTE: App-id for efcaching.ncconf should be same as in application (app.config) otherwise it will prompt an error)