Generating a New GemFire XD Schema from Model Objects

In the model first approach, you use Entity Data Model Tools to create an empty .edmx file, and then create the entities, relationships, and inheritance hierarchies required for your model. Generating a database from the model provides DDL commands that you can execute in GemFire XD to create the actual schema.

Procedure

  1. In the Solution Explorer, right-click your Windows Forms application and select Add > New Item...
  2. Select ADO.NET Entity Data Model from the Visual Studio installed templates.
  3. Click Add to display the Visual Studio displays the Entity Data Model Wizard. You will use this wizard to generate the new model.
  4. Select Empty Model from the Choose Model Contents window, and click Finish.
  5. Use the Toolbox or right-click the design surface to create the entities and associations that you want to include in your model. For example:

  6. Before you generate DDL for your model, be sure to select the SSDLToGemFireXD.tt (VS) option from the DDL Generation Template menu in the model's Properties panel:

  7. Right-click in the designer to display the context menu, then select Generate Database from Model.... This opens a Generate Database Wizard.
  8. On the Choose Your Data Connection window:
    1. Click New Connection...
    2. Click Change... to change the data source.
    3. Click <other> in the Data source: list.
    4. Select .NET Framework Data Provider for GemFire XD from the Data provider drop-down list:

    5. Click OK to select the provider. The GemFire XD provider is now selected in the Connection Properties dialog:

    6. In the Server field, enter the address and port number (separated by a colon) of the GemFire XD locator or server to use for connecting to the distributed system. For example, the above screenshot shows a connection to localhost:1527. Click Test Connection to verify that you can connect, then click OK to dismiss the test connection and connection properties dialog boxes.
    7. Select the Save entity connection settings in App.Config as: dialog box and provide a name for the settings:

    8. Click Next to continue. The Generate Database Wizard creates and displays the GemFire XD DDL commands that are required to create your completed model:

  9. Enter a filename for the DDL commands in the Save DDL As: field, and click Finish.
  10. If you intend to replace an existing schema with the model you have created, first backup all data in the existing database tables and drop those tables from the schema. See Exporting and Importing Data with GemFire XD.
  11. Execute the DDL file in GemFire XD to create the new schema. For example:
    gfxd run -file="c:\Users\yozie\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Model1.edmx.sql"
         -client-bind-address=localhost -client-port=1527
  12. If you replaced an existing schema with the model, import data into the new tables using the instructions in Exporting and Importing Data with GemFire XD.