dotConnect for MySQL Documentation
Generating Database from Model
support@devart.com

Entity Framework v4, v5, and v6 allow you to use Model First feature to generate database, and the SSDL, and MSL. In this article we consider how to use this functionality.

Note that this functionality is not supported in Entity Framework Core.

This feature provides a possibility to start from a conceptual model and then to generate the other parts of the EDM (Entity Data Model) and the database. Create Database from Model wizard can be used for database generation from an Entity Data Model in Visual Studio 2010 - 2019.

Entity Framework workflow for DDL generating from CSDL includes two actions. The first one generates SSDL and MSL from CSDL. It is common for all providers and cannot be customized independently. The second action is specific to Entity Framework provider and can be modified for specific DBMS.

Devart offers additional templates for database script generation.

The following steps will guide you through database generation wizard:

  1. Create an EF model. The given example shows a CRM_DEMO schema.
    Entity Framework model
  2. Select a corresponding template in the model properties window. Then right-click on the diagram and run the Create Database from Model wizard by choosing Generate Database from Model from the popup menu.
    generating database from model
  3. NoteNote:
    The default schema name for Microsoft SQL Server database is "dbo". Don't forget to change it to the necessary one before the code generation.
  4. Here is a DDL script generated for the current model.
    Generate Database Wizard - Summary and Settings

As a result of these steps you will obtain a valid database-specific DDL script. You can run this script against your database to create a valid database schema.

Please also note that dotConnect for MySQL goes with its own ORM designer - Entity Developer. It provides advanced Model First support and a number of other features, not available in Visual Studio EDM designer.

See Also

Entity Framework | Entity Framework Tutorial