Generating a New Model from a GemFire XD Schema
The Entity Framework plug-in enables you to generate identity objects from an existing GemFire XD schema.
If you have already created one or more database schemas in GemFire XD, you can use the ADO.NET Entity Framework plug-in to generate model objects using tables, views, procedures, and functions avaiable in the existing schema. To generate model objects, you first create a new Windows Forms application, and then you add an Entity Data Model using a connection to GemFire XD.
Create a Windows Forms Application
- Start Microsoft Visual Studio 2010 with Service Pack 1.
- Select File > New > Project... from the main menu.
- Select the installed template named Windows Forms Application and click OK to create the new solution..
- Follow the steps in the next section to add an Entity Data Model to the solution.
Add an Entity Data Model
- In the Solution Explorer panel, right-click your Windows Forms application and select Add > New Item...
- Select ADO.NET Entity Data Model from the list of installed templates.
- Click Add to display the Visual Studio displays the Entity Data Model Wizard. You
will use this wizard to generate the new model:
- Select Generate from database from the Choose Model Contents window, and click Next.
- On the Choose Your Data Connection window:
- Click New Connection...
- Click Change... to change the data source.
- Click <other> in the Data source: list.
- Select .NET Framework Data Provider for GemFire XD from the Data
provider drop-down list:
- Click OK to select the provider. The GemFire XD provider is now
selected in the Connection Properties dialog:
- 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.
- Select the Save entity connection settings in App.Config as:
dialog box and provide a name for the settings:
- Click Next to continue.
The Entity Data Model Wizard connects to the GemFire XD system and displays a tree structure of the database objects in the default schema:
- Select the database tables, views, and stored procedures that you want to include in your
model, then click Finish.Note: The Entity Framework plug-in supports importing existing stored procedures and functions as well as tables and views. In order to use existing procedures and functions with the imported model, you must map them to specific entity objects after the full schema has been imported. See XREF.
Visual Studio generates the model for the selected objects and relationships:
- Before you begin to modify the model, select Build > Build Solution from the Visual Studio main menu to ensure that the model compiles without error.
- If you chose to import Stored Procedures, then the Entity Data Model Wizard imports metadata both for stored procedures and functions in the GemFire XD schema. To use the imported procedures and functions, you must first map them as functions for an entity using the design surface. See XREF.
- You can modify the model, add entities, and so forth using the design surface and/or the Toolbox. To update the GemFire XD schema with your new model, you must first drop all database objects in GemFire XD and then recreate them using DDL commands generated from Visual Studio 2010. See Generating a New GemFire XD Schema from Model Objects for instructions.