Primary identifier mapping is mandatory in ADO.NET and ADO.NET CF. Primary identifiers of entity classes are mapped to primary keys of master tables in data sources. If not defined, a default primary identifier mapping will be generated, but this may not work properly.
Mapped classes must declare the primary key column of the database table. Most classes will also have a property holding the unique identifier of an instance.
There are three kinds of primary identifier mapping in ADO.NET and ADO.NET CF:
Simple identifier mapping - When a primary key is attached to a single column, only one attribute in the primary identifier can be mapped. This kind of primary key can be generated automatically. You can define increment, identity, sequence, etc., on the corresponding column in PDM.
Composite identifier mapping - If a primary key comprises more than one column, the primary identifier can have multiple attributes mapped to these columns. In some cases, the primary key column could also be the foreign key column. In the following example, the Assignment class has a primary identifier with three attributes: one basic type attribute and two migrated attributes:
Component identifier mapping - For more convenience, a composite identifier can be implemented as a separate value type class. The primary identifier has just one attribute with the class type. The separate class should be defined as a value type class. Component class mapping will be generated then. In the example below, three name attributes are grouped into one separate class Name, which is mapped to the same table as the Person class.