Telerik blogs
As many of you know, the change tracking in OpenAccess ORM is implemented using code injection during the build process of your Data Access Layer. A brief overview of the tool that is performing this task - the OpenAccess Enhancer - is provided here. When using MSBuild, there is a standard approach for integrating OpenAccess ORM Enhancer tool in your build process, described in this documentation article. But how would you go if your build tool of choice is NAnt? In this blog post I will demonstrate how to integrate OpenAccess ORM and NAnt.

There are a few important steps that need to be implemented in order to automate an OpenAccess domain model using NAnt. The NAnt build definition includes several targets which will be used to automate the build process for the given OpenAccess ORM domain model. A target is a set of tasks which are executable piece of code.

-          Clean target – this is an optional target. It is used to clean up the build folder;

<target name="clean">
        <include name="${build.dir}/*.*" />


-          Build target – builds the source files, embeds the rlinq file as a resource, defines the needed references and copies the necessary OA assemblies;

<target name="build" depends="clean">
  <mkdir dir="${build.dir}"/>
  <csc target="exe" output="${build.file}" debug="${debug}">
      <include name="${source.dir}/*.cs"/>
      <include name="${source.dir}/MyModel.rlinq" />
      <include name="System" />
      <include name="System.Core" />
      <include name="System.Data" />
      <include name="Lib/Telerik.OpenAccess.dll" />
      <include name="Lib/Telerik.OpenAccess.35.Extensions.dll" />
  <copy todir="${build.dir}">
    <fileset basedir="${lib.dir}">
      <include name="Telerik.OpenAccess.dll" />
      <include name="Telerik.OpenAccess.35.Extensions.dll" />
  <copy file="${source.dir}/App.config" tofile="${build.file}.config" />


-          Enhance target – runs the OpenAccess ORM Enhancer over the built project using the rlinq file as a metadata source;

<target name="enhance" depends="build">
  <exec program="${enhancer.file}">
    <arg value="-assembly:"${build.file}" -xmlMapping:${source.dir}/MyModel.rlinq"/>


Note the exec task’s arguments listed above. They are providing the enhancer with the built assembly, which will be enhanced, and its metadata source. The metadata source will be used to obtain the metadata container which describes the domain model metadata. In this example the domain model is using an XML mapping. There can be scenarios where the model is defined using attributes or fluent mapping. It is possible to combine all of the mapping types in one OpenAccess ORM project.

I hope this tutorial proves useful for your NAnt build processes. The complete demo application can be found here

About the Author

Damyan Bogoev

Damyan Bogoev is Senior Software Developer in OpenAccess ORM Team

Related Posts


Comments are disabled in preview mode.