When you use the Fluent Mapping API, you need to create a custom fluent context class that derives from the OpenAccessContext class. It will represent the shape of your model and will act as a gateway to your database. Next you could start writing queries against your context, load data, insert, update and delete objects from the database. OpenAccessContext resides in the Teleri.OpenAccess.35.Extensions assembly, which along with the rest of the required Data Access assemblies, Enhancer, and the OpenAccessNuGet.targets file, is delivered to you by the Telerik.DataAccess.Fluent and Telerik.DataAccess.Core NuGet packages. Usually, you will integrate the project that holds your model with these packages and the code for the post-build enhancement action will be added to your project file by NuGet Package Manager. But if the assemblies and Enhancer are already available on your machine, you may decide to perform the integration manually. In this case, besides adding references to the assemblies in your project, you will have to to integrate the call to Enhancer as well.
This tutorial will guide you through the process.
- Copy the OpenAccessNuget.targets file inside your project folder and include it in the project.
- Right-click on your project in the Solution Explorer and select Unload Project.
- Again in the Solution Explorer, right-click on the unloaded project and select Edit ProjectName.csproj.
In your csproj file, find a line like this one:
<!-- It is not necessary the value to be Debug --> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
And add the path to Enhancer. In this example, it is assumed that Enhancer is located in a custom folder under the packages folder inside the solution directory:
Go further down the .csproj file and find a line like this one:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
After it paste the following import clause:
<Import Project="OpenAccessNuget.targets" />
Save your changes. Right-click on your project in the Solution Explorer and select Reload Project.
By implementing the above-mentioned steps you guarantee that the Telerik Data Access Enhancer will be integrated with your Fluent Mapping project. Check out the next topic to see how to troubleshoot your fluent mapping applications.