Before creation of mapping ECSchema should be opened in advance. To create new mapping perform below operations.
To open an existing mapping for ECSchema do the following steps:
→ It is also possible to remove a mapping by selecting it in the list and clicking the "Remove" button
Note: A schema doesn't need to be opened in advance. The appropriate schema will be opened automatically while opening the mapping.
To save a mapping select "Database Mapping > Save..." menu item or right click on the schema in tree and choose "Save Mapping" from the context menu. If a mapping file already exists it will be overridden, if not an new mapping file will be created
To close an opened mapping select "Database Mapping > Close" or right click on the schema in the ClassEditor navigation tree and chose "Close Mapping" from the context menu.
In practice sometimes an APPlugin may work with two or more schemas. One schema may have base classes shared among several applications and the second can reference the first schema and contain derived classes with additional properties. The mapping file can contain mappings for all working schemas. The schema that references others will be considered as master. To allow the mapping of classes of any referenced schema it is sufficient to open it in the ClassEditor. After that it is possible to perform all operations with its classes like with classes of master schema.
To locate mappings the Plant Poject Database Mapping Extension uses the ECSCHEMA_PATH environment variable. The variable contains a list of folders where ECSchemas are located. The mapping plug-in searches these folders for existing mapping files. All mappings for a schema are located in a subfolder of the schema folder. The subfolder has the following name pattern:
The folder contains all mappings of all application for that schema. The name pattern for a mapping file is the following:
After a mapping is opened or created the Plant Project Database Mapping Extension panel is displayed on the right of the ClassEditor. It consists of two tabs (see Fig.6). The first tab is "Summary". It contains overall information about the mapping and provides some statistics. The second tab is "Class Mapping" or "Relationship Mapping". The name depends on what has previously been selected: class or relationship. It provides overall information about the currently selected class mapping and property mapping.
The Summary tab contains overall information about the whole schema mapping and has the following sections:
Export Summary: When clicking the Export Summary button a summary is saved in a RichText file.
Edit Database Structure: Opens a tool that allows loading and editing the Plant Project Database structure. For more information about database structure and operations with it see Database Structure.
Under this tab the overall information about the selected class or relationships mapping (on the top) and the selected property (on the bottom) is displayed. The class related part contains the following sections:
From the class mapping tab it is possible to activate or deactivate a mapping, add a new mapping, edit and remove a mapping. For more information see Class Mapping.
The property related panel contains more detailed information about the selected property. As for a class it is possible to activate or deactivate a mapping, add a new mapping, edit and delete a property mapping. For more detail see Property Mapping. The information of a property has the following sections:
In order to simplify the process of creating a mapping and provide the necessary validation a mapping file contains a model of the application database structure (only structure without data). If an application uses several databases then all of them should be included in the mapping file. A mapping doesn't contain the complete information about a database, but it contains the most significant information for generating the proper statements for reading and writing objects.
Database structure is stored in provider independent format. It is possible to load structure using several providers:
5.1 Loading database structure
The database structure is necessary to perform any editing on the mapping. After creation of a new mapping it should be loaded. The operation includes the following steps:
The loaded database is displayed in the Database Structure Editor dialog box. The dialog box has two parts: The Navigation pane (on the left) and the Details pane (on the right). For a selected database item the detailed information is displayed in the details pane.The navigation pane allows to navigation over all main items of the database:
The Database Editor also supports the editing of a database structure (creation of new database, editing tables and columns, indeces and keys). By default this feature is disabled. To enable it you need to add an option in the Class Editor configuration file (ECClassEditor.exe.config):
<?xml version="1.0" encoding="utf-8" ?><configuration>... <appSettings> ... <add key="IsDBStructureEditable" value="True" /> ... </appSettings></configuration>
Note: the ECClassEditor.exe.config file is located underneath the Program Files folder and you need administrator rights in order to make changes to it