Spec-Zone .ru
спецификации, руководства, описания, API

22.2.4.9. Tutorial: Generating MySQL DDL from an Entity Framework Model

In this tutorial, you will learn how to create MySQL DDL from an Entity Framework model. Use Visual Studio 2010 and MySQL Connector/Net 6.3 to carry out this tutorial.

  1. Create a new console application in Visual Studio 2010.

  2. Using the Solution Explorer, add a reference to MySql.Data.Entity.

  3. From the Solution Explorer select Add, New Item. In the Add New Item dialog select Online Templates. Select ADO.NET Entity Data Model and click Add. The Entity Data Model dialog will be displayed.

  4. In the Entity Data Model dialog select Empty Model. Click Finish. A blank model will be created.

  5. Create a simple model. A single Entity will do for the purposes of this tutorial.

  6. In the Properties panel select ConceptualEntityModel from the drop-down listbox.

  7. In the Properties panel, locate the DDL Generation Template in the category Database Script Generation.

  8. For the DDL Generation property select SSDLToMySQL.tt(VS) from the drop-down listbox.

  9. Save the solution.

  10. Right-click an empty space in the model design area. The context-sensitive menu will be displayed.

  11. From the context-sensitive menu select Generate Database from Model. The Generate Database Wizard dialog will be displayed.

  12. In the Generate Database Wizard dialog select an existing connection, or create a new connection to a server. Select an appropriate radio button to show or hide sensitive data. For the purposes of this tutorial you can select Yes (although you might skip this for commercial applications).

  13. Click Next. MySQL compatible DDL code will be generated. Click Finish to exit the wizard.

You have seen how to create MySQL DDL code from an Entity Framework model.