This project is read-only.

The default processor of TFDP uses template mappings to configure which templates are used for specific model element types. In the getting started video the template mapping editor makes an appearance. This page gives an overview of the template mapping editor.

Template Mappings editor

For each mapping you can specify the following options:

  • Enabled/Disabled
  • Model element type
  • Template file
  • Target project
  • Object name template
  • File name template
  • Order

These options are described below in more detail. Note that all these options are mandatory and the mapping won't work if one of the options is not set.


Use option to enable or disable a template. Useful if you have multiple templates and you're currently creating a new template. By disabling other templates you can prevent other templates from triggering.

Model element type

This specifies for which type of model element the template is used. This can be any element that derives from IModelElement. See the VSTDB API for the types that are available.

Template file

The template that should be used. This drop-down is populated by the T4 files that exist in the template directory that is configured for this project

Target project

The project in which the generated artifact should be placed. This drop-down is populated with all the projects in the current solution.

Object name template

This format is used to specify the name of the generated artifact. For example: to generate a table with the name <OriginalTable> + Suffix the format should be {elementName}Suffix.
The following variables are available:

  • {schema} the schema name of the source object
  • {element} the short name of the source object
  • {elementFullName} the full name (includes schema name) of the source object

Note that this is the name used to resolve the generated artifact in the database project. For other project types this is ignored.

File name template

The format for the file name that is used for the generated artifact. This field supports the same variables as the object name template.
The path is specified as relative to the root of the target project.


The order in which the template should be processed. This option can be used to make sure that some templates are processed before others for example when there are dependencies between generated artifacts of different templates. 



To add a new template mapping simply click "Add" in the right side of the editor window. This will add a new line in the grid where you can specify the options for the template mapping. It's possible to add several mappings for the same model element type, the mappings will then be processed sequentially. 


Consider the following situation: I want to generate a audit table for existing tables in the database project and I want to use the template for this purpose.

The template mapping should be added like this:

Option Value
Enabled Yes
Type ISqlTable
Project TDFPSample
Object name template {schema}.{element}Audit
File name template

\Schema Objects\Schemas\{schema}\Tables\{element}Audit.table.sql



These settings will create a generated artifact that is named <Table name>Audit (for example UserAudit) and add this table to the file \Schema Objects\Schemas\dbo\Tables\<Table name>Audit.table.sql

Last edited Sep 6, 2011 at 9:32 AM by sandermvanvliet, version 5


No comments yet.