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

How to: Customize Service Wizard Code Generation

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

You can customize the result of the code generation step by modifying the T4 code generation templates that are used by the Service Wizard. The customization process includes the following steps:

  1. Preparation of the project that hosts the service
  2. Preparation of the templates
  3. Customizing the templates
  4. Running the Service Wizard

1. Preparation of the project that hosts the service

  • Create a new folder named OpenAccessTemplates in the host project. The Service Wizard is generally looking for code generation templates from the host project first and then from the Telerik Data Access installation folder.

  • Copy the necessary templates in the OpenAccessTemplates folder according to the lists below and include them in the project:

I you are already aware of the templates you need to modify for the particular service you use, you can copy only them in the OpenAccessTemplates folder.

For ASP.NET Web API Service:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • Global.asax.Routes.tt
  • WebApiBaseApiController.tt
  • WebApiBaseRepository.tt
  • WebApiController.tt
  • WebApiRepositories.tt

For WCF Plain Service:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • PlainDataService.svc.tt
  • PlainDataService.tt
  • PlainIDataService.tt

From <install-dir>\dsl20XX\CodeGenerationTemplates\Dto\<language>\

  • The Includes folder
  • Assemblers.tt
  • ContextFactory.tt
  • DynamicLinq.tt
  • KeyConverter.tt
  • Repositories.tt
  • Services.tt
  • Transport.tt
  • UnitOfWork.tt

The OpenAccessTemplates folder should contain all *.tt files from the list and an Includes subfolder with four *.ttinclude files.

For WCF Data Service - OData v3:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • Astoria3DataService.svc.tt
  • Astoria3DataService.tt

For WCF Data Service - OData v1:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • Astoria1DataManager.tt
  • Astoria1DataService.svc.tt
  • Astoria1DataService.tt
  • Astoria1DataServiceKeys.tt

For RESTful Collection Service:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • RestDataService.svc.tt
  • RestDataService.tt
  • RestIDataService.tt
  • RestItemInfo.tt
  • RestItemInfoList.tt

From <install-dir>\dsl20XX\CodeGenerationTemplates\Dto\<language>\

  • The Includes folder
  • Assemblers.tt
  • ContextFactory.tt
  • DynamicLinq.tt
  • KeyConverter.tt
  • Repositories.tt
  • Services.tt
  • Transport.tt
  • UnitOfWork.tt

The OpenAccessTemplates folder should contain all *.tt files from the list and an Includes subfolder with four *.ttinclude files.

For AtomPub Service:

From <install-dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\

  • The Includes folder
  • AtomDataService.svc.tt
  • AtomDataService.tt
  • AtomIDataService.tt

From <install-dir>\dsl20XX\CodeGenerationTemplates\Dto\<language>\

  • The Includes folder
  • Assemblers.tt
  • ContextFactory.tt
  • DynamicLinq.tt
  • KeyConverter.tt
  • Repositories.tt
  • Services.tt
  • Transport.tt
  • UnitOfWork.tt

The OpenAccessTemplates folder should contain all *.tt files from the list and an Includes subfolder with four *.ttinclude files.

2. Preparation of the templates

Once the templates are included in your project, you will notice that Error List in Visual Studio will notify you of some errors. They occur because the templates delivered by Telerik Data Access require additional steps performed by the Service Wizard. In order to avoid them you need to do the following:

  • Delete the .cs\ .vb file under each .tt file
  • Delete the content of the Custom Tool property for every .tt file

3. Customizing the templates

At this stage you are ready to perform the necessary custom changes in the templates

4. Running the Service Wizard

When you are ready to test the outcome from the customization, you can run the Service Wizard

In case your project is tracked by a source control system, we recommend that the whole OpenAccessTemplates folder is checked-in with it. That allows the entire team to work with the hosting project without any risk for the changes in the templates or in the generated service files to be rewritten.