Data Access has been discontinued. Please refer to this page for more information.

Identity Per Configuration Level

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Fluent Mapping API allows you to define an identity key per configuration level. This can be done via the HasIdentity method. The HasIdentity has two overloads. The first one accepts a KeyGenerator object as a parameter. When you specify only a KeyGenerator, then an internal identity will be used. That means that Telerik Data Access will create at runtime an internal column, which will be used as an identity.

personConfiguration.HasIdentity( KeyGenerator.Autoinc );
personConfiguration.HasIdentity( KeyGenerator.Autoinc )

The second overload explicitly specifies all properties that will be part of the identity.

personConfiguration.HasIdentity( p => p.Id );
personConfiguration.HasIdentity( p => p.Id )

Note that the following two statements are identical and will achieve the same goal:

  • personConfiguration.HasIdentity( p => p.Id )
  • personConfiguration.HasProperty( p => p.Id ).IsIdentity()