DbMappings
The dbMappings section is where you can configure, for your dbContext, all mappings between business entities and database tables, as well as map the properties/columns and relationship objects.
Fields
A dbMapping contains the following fields to be defined:
Name
The name of dbMapping to be created.
Requirements Rules:
- Is Required;
- Must not be a Reserved Keyword;
- Must start with a letter;
- Must contains only letters, numbers and the underline char ('_');
- Max length of 50 chars
Example:
1 2 |
|
EntityName
The name of business entity to be mapped in this dbMapping.
Requirements Rules:
- Is Required;
- The name must exist in Entities list in the current model;
- See Entity section for more details.
- DbMapping is not allowed for entities without the KeyType property
Example:
1 2 3 |
|
Table
The name of data table in your database that refers to the current business entity.
It is necessary when the table name is different from the entity name.
Requirements Rules:
- Must start with a letter;
- Must contains only letters, numbers and the underline char ('_');
- Max length of 128 chars
Example:
1 2 3 4 |
|
Comment
It allows configuring a comment to be applied to the table at the time of it's creation.
Requirements Rules:
- Max length of 500 chars
Example:
1 2 3 4 5 |
|
AlternateKeys
A collection of entity properties list, where each list will be used to create an alternate key for the entity at database table.
With this option, the property becomes read-only. If you just want to enforce uniqueness on a column, define a unique index rather than an alternate key.
Each key in the collection must contains one or more property names.
Note
The Entity Framework cannot track alternative keys for properties whose value is null.
If the alternative key property is nullable and is not used in a relationship, consider using a unique index instead.
For more info, see this issue: Optional alternate key properties | GitHub
Requirements Rules:
- All property names in the collection keys must exist for the current entity
Example:
1 2 3 4 5 6 7 |
|
Indexes
A collection of entity properties, where each item will be used to create an index for the entity at database table. Gives the option of defining unique index.
Requirements Rules:
- Each index on list must follows rules as specified in DbMapping Indexes;
Example:
1 2 3 4 5 6 7 8 9 10 |
|
Properties
The list of entity properties to be mapped in this dbMapping.
Requirements Rules:
- Each property on list must follows rules as specified in DbMapping Property;
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Relationships
The list of relationship objects to be mapped to the current entity in this dbMapping.
Requirements Rules:
- Each relationship on list must follows rules as specified in Relationship;
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|