Kentico CMS 7.0 Developer's Guide

Custom Data provider

Custom Data provider

Previous topic Next topic Mail us feedback on this topic!  

Custom Data provider

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Customization of the data provider allows you to implement your own database connector.


You cannot modify the data provider in the App_Code folder. The customizations must be added as part of a new assembly, which you then need to register via the CMSDataProviderAssembly web.config key.







Custom data providers are NOT intended for accessing non-Microsoft SQL Server database engines. They only allow you to modify how queries are executed against the Microsoft SQL Server.



Adding the custom data provider assembly


1. Copy the CustomDataProvider project from your Kentico CMS installation directory (typically C:\Program Files\KenticoCMS\<version>\CodeSamples\CustomDataProvider) to a development folder.


2. Open your CMS web project in Visual Studio through the WebProject.sln file (or WebApp.sln if you are using a web application installation).


3. Click File -> Add -> Existing Project and select CustomDataProvider.csproj in the folder where you copied the CustomDataProvider project.


4. Unfold the References section of the CustomDataProvider project and delete all invalid references.


5. Right-click the CustomDataProvider project and select Add Reference.


6. Open the Browse tab of the Add Reference dialog and navigate to the bin folder of your CMS web project on the disk.


7. Add references to the following libraries:





8. Right‑click the CMS website object (or the CMSApp project if your installation is a web application) and select Add Reference.


9. Open the Projects tab and add a reference to the CustomDataProvider project.


The CustomDataProvider project is now integrated into your application. By default, the classes in the custom data provider are identical to the ones used by default, but you can modify them according to your own requirements. Remember to Build the CustomDataProvider project after making changes.


Registering the custom data provider


1. Edit your application's web.config file.


2. Add the following key to the configuration/appSettings section:

<add key="CMSDataProviderAssembly" value="CMS.CustomDataProvider"/>


The system loads the DataProvider class from the namespace specified as the value of the CMSDataProviderAssembly key.


Your application now uses the custom data provider for handling database operations.