Session: How to Customize the Identity Property Lookup for Entities

The client must know which property of your entity is considered as an identity. By default, it always looks for the Id property (case-sensitive). This behavior can be changed by overwriting one of our conventions called FindIdentityProperty.


Func<MemberInfo, bool> FindIdentityProperty { get; set; }

MemberInfo will represent the member of a stored entity, and return value (bool) will indicate if given member is an identity property.


The simplest example would be to check if the property name is equal to 'Identifier'.

store.Conventions.FindIdentityProperty = memberInfo => memberInfo.Name == "Identifier";