Udostępnij za pośrednictwem


How to: Customize Database Generation (Generate Database Wizard)

This topic describes how to customize the data description language (DDL) that is generated by the Generate Database Wizard (Entity Data Model Tools). For information about the default DDL that is generated, see Database Generation Rules (Generate Database Wizard).

The Create Database Wizard uses Windows Workflow Foundation and text templates to perform the following steps:

  1. Generate store schema definition language (SSDL) that is based on your conceptual model.

  2. Generate mapping specification language (MSL) that maps the SSDL to your conceptual model.

  3. Generate DDL based on the SSDL.

The default workflow and default text template that are used by the Create Database Wizard are specified in the Database Generation Workflow and DDL Generation Template properties of a conceptual model. The following procedures describe how to configure your project so that the Create Database Wizard uses a custom workflow or a custom text template (or both) in the DDL generation process. The procedures assume that you have an .edmx file open in the Entity Data Model Designer (Entity Designer) and that you have designed a conceptual model.

NoteNote

Customizing either the workflow or the text template usually requires customizing both.

To customize the database generation workflow

  1. Add a custom Windows Workflow (a .xaml file) to your project or put your custom .xaml file in the following location: %localappdata%\Microsoft*\[AppId]*\10.0\Extensions\Microsoft\Entity Framework Tools\DBGen where [AppId] depends on your Visual Studio edition.

  2. Right-click the Entity Designer surface and select Properties.

  3. Set the value of the Create Database Workflow property to the path of your custom .xaml file relative to your project directory. You can also use the full path of your custom .xaml file. Files put in the path shown in step one will be available as property values (the value will be the file name appended with (User)).

    The Create Database Wizard will now use the specified workflow when generating DDL from your model. The workflow will use the text template specified in the DDL Generation Template property to generate DDL from SSDL.

NoteNote

Do not modify the default .xaml file used by the Create Database Wizard. You can, however, modify a copy of the default .xaml file and then follow the previous instructions.

To generate DDL, launch the Create Database Wizard. For information see, see How to: Generate a Database from a Conceptual Model (Entity Data Model Tools).

To customize the SSDL-to-DDL generation

  • Add a custom text template (a .tt file) to your project or put your custom text template in the following location: %localappdata%\Microsoft\[AppId]\10.0\Extensions\Microsoft\Entity Framework Tools\DBGen where [AppId] depends on your Visual Studio edition.

    NoteNote

    When you add a .tt file to your project, a Security Warning will appear. For more information, see Security of Text Templates.

  1. Right-click the Entity Designer surface and select Properties.

  2. Set the value of the DDL Generation Template property to the path of your custom .tt file relative to your project directory. You can also use the full path of your custom .tt file. Files that you put in the path that is shown in step one will be available as property values. The value will be the file name appended with (User).

    The Create Database Wizard will now use the specified text template when generating DDL from SSDL.

NoteNote

Do not modify the default .tt file used by the Create Database Wizard. You can, however, modify a copy of the default .tt file and then follow the instructions above.

To generate DDL, launch the Create Database Wizard. For information see, see How to: Generate a Database from a Conceptual Model (Entity Data Model Tools).

See Also

Tasks

How to: Customize Object-Layer Code Generation (Entity Data Model Designer)

Concepts

.edmx File Overview (Entity Framework)
Extending the Entity Data Model Tools

Other Resources

Windows Workflow Foundation
Developing Workflows