Defining Generation Paths in Templates

The standard T4 generator implements the IVsSingleFileGenerator interface and by default generates one file per template. Entity Developer extends this behavior using the Output class. Example: the entity-generating template generates one single cs file that is included into the .tt file project item, which is not very convenient in large projects.

All templates have the FilePerClass option as well as the EntitiesOutput and ContextOutput. EntitiesOutput and ContextOutput provide a capability that slightly differs in Visual Studio and in the stand-alone version, as described below.

If you are using Entity Developer as a Microsoft Visual Studio add-in, you can define the project and project folder to store generated code for entities, context and mappings (if applicable) of your model. In the Entity Developer stand-alone application, it is possible to define folders, in which generated code for entities, context and mappings (if applicable) is to be stored.

This set of options makes the development of multilayer applications easier and more convenient.

Using the properties of templates, available in Entity Developer, you can define paths to the folder, in which generated code for entities and contexts will be stored. The procedures for defining the paths are different, depending on whether you use the Microsoft Visual Studio add-in or the stand-alone application.

 

ExpandedToggleIcon        How to Define Generation Paths in Visual Studio Add-In

In the Visual Studio add-in, you can define the project and the folder for the generation of entities, context and mappings (if applicable). For that purpose, perform the following steps:

1.In the Model Explorer window, select the required template.
2.Right-click the selected template and select Properties from the shortcut menu.
3.To define the project and project folder for context generation files, click in the Context Output line of the Properties window and then click the three-dotted button.

note Note

This option is available for Entity Framework, LINQ to SQL and LinqConnect templates.

4.In the Select Project Folder dialog box, navigate to specify the folder, in which the generated files are to be stored.
5.To define the project and project folder for entities generation files, click in the Entities Output line of the Properties window and then click the three-dotted button.
6.In the Select Project Folder dialog box, navigate to specify the folder, in which the generated files are to be stored.
7.Set the File Per Class property value to True.
8.To define the project and project folder for mapping files generation, click in the Xml Mapping Output line of the Properties window and then click the three-dotted button.

note Note

This option is available for NHibernate templates only.

9.In the Select Project Folder dialog box, navigate to specify the folder, in which the generated files are to be stored.

note Note

When defining the project and project folder, you can specify a project that is different from the current one.

 

ExpandedToggleIcon        How to Define Generation Paths in the Entity Developer Stand-alone Application

In the Entity Developer stand-alone application, you can define destination folders for the generation of entities, context and mappings (if applicable). For that purpose, perform the following steps:

1.In the Model Explorer window, select the required template.
2.Right-click the selected template and select Properties from the shortcut menu.
3.To define the path for context generation files, click in the Context Output line of the Properties window and then click the three-dotted button.

note Note

This option is available for Entity Framework, LINQ to SQL and LinqConnect templates.

4.In the Browse For Folder dialog box, navigate to specify the folder, in which the generated files are to be stored.
5.To define the path for entities generation files, click in the Entities Output line of the Properties window and then click the three-dotted button.
6.In the Browse For Folder dialog box, navigate to specify the folder, in which the generated entities files are to be stored.
7.Set the File Per Class property value to True.
8.To define the path for mapping files generation, click in the Xml Mapping Output line of the Properties window and then click the three-dotted button.

note Note

This option is available for NHibernate templates only.

9.In the Browse For Folder dialog box, navigate to specify the folder, in which the generated mapping files are to be stored.

The advantage of this functionality is that you do not have to redefine these paths once the project is moved to another machine.

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.