Data Access has been discontinued. Please refer to this page for more information.

Telerik® Data Access .targets files

This article will help you familiarize yourself with the purpose of the OpenAccessNuGet.targets file - why is it needed and which are the default settings it defines.

Why is a .targets file necessary?

The OpenAccessNuGet.targets file is deployed by the Telerik.DataAccess.Fluent NuGet. It is loaded and used by the project containing the Telerik Data Access model to call the Telerik Data Access Enhancer as a post-build step. The Enhancer will add the persistent capability, change tracking, and lazy loading functionality to the model. Due to this approach you will write less code, the fluent model will be cleaner and the persistent classes more simple thus reducing the time you will need for development and testing.

Project settings

The OpenAccessNuGet.targets file defines the default values of the settings controlling the behavior of the Enhancer. These default values are used when there are no explicitly defined values for the respective settings in the .csproj or .vbproj files of the project which is to be enhanced.

OpenAccessNuGet.targets settings:

    <UseXmlMapping Condition="'$(UseXmlMapping)'==''">false</UseXmlMapping>
    <UseAttributeMapping Condition="'$(UseAttributeMapping)'==''">false</UseAttributeMapping>
    <UseFluentMapping Condition="'$(UseFluentMapping)'==''">true</UseFluentMapping>
    <EnhancerAssembly Condition="'$(EnhancerAssembly)'==''">enhancer.exe</EnhancerAssembly>
    <EnhancerVerboseMode Condition="'$(EnhancerVerboseMode)'==''">3</EnhancerVerboseMode>
    <Use64BitEnhancer Condition="'$(Use64BitEnhancer)'=='' And '$(PlatformTarget)'=='x64'">
    <ValidateMapping Condition="'$(ValidateMapping)'==''">false</ValidateMapping>
  • UseXmlMapping - this setting specifies whether models using Xml Mapping should be enhanced by the Enhancer. The default value is false.
  • UseAttributesMapping - this setting specifies whether models using Attributes Mapping should be enhanced by the Enhancer. The default value is false.
  • UseFluentMapping - this setting specifies whether models using Fluent Mapping should be enhanced by the Enhancer. The default value is true.
  • EnhancerAssembly - this setting contains the relative path to the Enhancer executable. The default value enhancer.exe is just a place holder. The actual path to the Enhancer executable is added to the .csproj or .vbproj file by the NuGet package install script.
  • EnhancerVerboseMode - this setting specifies what information the Enhancer will display in the Error List window in Visual Studio. The default value is 3. There are three possible values:
    • 2 - errors
    • 3 - errors and warnings
    • 4 - errors, warnings and information
  • Use64BitEnhancer - depending on the platform target for the project, this setting automatically determines whether to call the Enhancer in a 32 or 64 bit process. For projects with target platform AnyCPU or x86 the Enhancer will be called in a 32 bit process. For projects with target platform x64 the Enhancer will be called in a 64 bit process.
  • ValidateMapping - this setting specifies whether the mapping of the model should be validated when the containing project is being build. The default value is false. We recommend you not to change the default value of this setting.

The boolean values for the settings must always be specified with lower case.

Why is the OpenAccessNuget.targets file included in the project?

The Telerik.DataAccess.Fluent NuGet package adds the OpenAccessNuget.targets file to the project in which is installed. This file needs to be loaded by the project right after the C# or VB .targets file, on all development and testing machines. For this reason instead of storing the .targets file in the Packages folder in the solution, we recommended adding it within the project itself. This way it will be handled by the source control in which the project is included and will still be loaded successfully by the project even if you depend on the NuGet Package Restore functionality.