The Field Mappings tab is the tab which contains the information and editors for working with the mappings of the entity definition on a target element in the Relational Model Data, e.g. a table or a view. The different parts are described below.
An entity can be mapped to multiple targets, one target per database type. A database type represents a single Relational Model Data Storage container, you can have one of these per database type per project.
To map an entity to a target, you first select the Relational Model Data Storage container using the combo box called Database type. Then, you click the Create mapping button to create a mapping definition for this entity. The Remove mapping button removes the mapping definition. Each mapping connects a model element (e.g. entity) and a Relational Model Data element, e.g. a table or a view, which is called the target of the mapping. To select which table or view an entity maps to for the chosen database type, select the target from the combo box called Target. To view the specifics of the target chosen, click the button next to the target combo box to look it up in the Catalog Explorer. If you want to create a new target for an entity, you can click the New target button to open the dialog to specify the name for a new table. You can also create a new target (and auto-map fields) by right-clicking the 'Entities' node in the Project Explorer and selecting 'Auto-map unmapped entities'.
Some databases, like Oracle and PostgreSql, support schema sequences. To create a new one, click the New sequence... button to open the name specification dialog for the new sequence. If you create a new target table using the 'New target...' button, and you want to use sequences in your database, it's recommended that you also create a new sequence.
Below the information for the entity mapping are the mappings per entity field shown. Per entity field which should be mapped (this is the set of fields in the entity, (inherited) primary key fields (in some inheritance hierarchies) and fields in used Value Type Definitions), the .NET type of the entity field is given and the target field it is mapped on. The target field is a field in the Target of the mapping. To select a target field, click the cell in the Target element name column to open the selector to pick the specific target field. The details about the selected target field are shown in the selector and for the selected field mapping also below the grid in the Target element details section, which is described below.
LLBLGen Pro contains auto-map functionality which already pre-selects target fields based on entity field name and type specifics. This greatly reduces time spend on mapping an entity to a target.
To specify a sequence to use for a specific field, you can do that in the 'Sequence' column. Click the cell to bring up the sequence selector. For example to mark the field 'OrderId' in the 'Order' entity as 'identity' for the mapping on the 'Orders' table in the SQL Server Relational Model Data, select the 'SCOPE_IDENTITY()' sequence for 'OrderId' in the Sequence column.
When using auto-mapping, by default, LLBLGen Pro will assign a sequence to all integer typed identifying fields: if the target database supports system sequences like SQL Server, the preferred system sequence is chosen. If the target database doesn't support system sequences, it will create a new sequence using the SequencePattern defined in the Project Settings. You can switch this auto-assignment off in the Project properties, set the setting 'AutoAssignSequencesToIntegerPks' under 'Designer behavior' to false (uncheck the checkbox).
Sometimes the .NET type of the entity field and the target field don't match. To match them, use a type converter and assign it to the particular field mapping by clicking the cell in the column 'TypeConverter to use'. Type converters are supported by the target frameworks: LLBLGen Pro RTL and NHibernate. Type converters for NHibernate have to implement IUserType as well as NHibernate only supports converts which implement that specific interface.
To synchronize the type specifics (.NET type, length, precision, scale) between the entity field and the mapped target field, you can use the Sync selected... button. You have two choices:
When an entity field has to be mapped onto a new target field, you can either use the New field... button at the bottom or click the Auto-map unmapped fields to new target fields button, which automatically creates new fields in the Target of the mapping, using the type specifics and names of the entity fields which aren't mapped to a target field yet. Several settings in Project Settings control the pre-selected type and the name construction of the newly created target fields.
When there are some unmapped target fields in the Target of the mapping and you want to reverse engineer them to entity fields using the reverse engineering functionality of the designer, click the button Reverse-engineer unmapped target fields.
The bottom section of the Field mappings tab contains the Target element details section, which displays the specific aspects of the target field of the selected row in the field mapped grid. To edit these specifics, click the Edit field... button, which will bring up the table field editor. You can only edit table fields, as view fields can't be altered.
If you want to create a new field in the Target of the mapping, click New field... which will bring up the same dialog as 'Edit field...' except it now allows you to specify a new field's specifics.
If you want to map the currently selected entity field to a new field, and don't want to spend time on specifying field specifics, you can click Auto-new field which creates a new target field in the Target of the mapping based on the selected entity field and maps the entity field on this newly created target field.
If the Target of the mapping isn't a table, you can't edit a target field nor create new ones.