xpo-3334-create-a-data-model-generating-persistent-objects-for-existing-data-tables.md
XPO supports the database-first development approach: you can generate persistent objects for your existing databases with no coding with a wizard. XPO installation ships with a design-time wizard that allows you to generate persistent objects for one or more data tables in your database at the same time.
Refer to the Basics of Creating Persistent Objects for Existing Data Tables topic for information on how to implement persistent classes manually.
Note
The wizard does not support data tables whose primary keys are composed of multiple columns. These tables are neither displayed nor processed by the wizard.
Select the Add | New Item… command from the context menu in Solution Explorer.
Select the DevExpress ORM Data Model Wizard item in the invoked dialog window, specify the data model name (for example, MyDataModel) and click Add.
In the invoked Data Model Wizard, select Map to an existing database and click Next. Specify connection settings to the database containing a target data table(s):
In the next step, the wizard displays a list of tables that can be mapped to persistent objects.
The names of persistent classes and their properties match the names of selected tables and their columns. You can add/remove custom prefixes and suffixes, and change the case style of names (for example, capitalize names). The wizard displays the resulting names. You can edit them later in the Data Model Designer. The classes and properties with modified names are mapped to the corresponding tables and columns using the PersistentAttribute attribute.
Note
If you do not want to use the Data Model Designer and prefer to edit generated classes manually, do the following:
Note
You can try the functionality described here in the Querying a Data Store | Generating Persistent Classes for an Existing Database section of the XPO Tutorials demo (C:\Users\Public\Documents\DevExpress Demos 25.2\Components\WinForms\Bin\XpoTutorials.exe).
See Also
Basics of Creating Persistent Objects for Existing Data Tables