.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

KeyAttribute.AutoGenerate Property

Gets or sets whether the key is generated automatically.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.2.dll


public bool AutoGenerate { get; set; }

Property Value

Type Description

true to generate the key automatically; otherwise, false.


Automatic key generation is supported for Int32, Int64 and Guid type keys. Guid key values are always generated on the client side, while Int32 and Int64 key values are generated using database facilities. Based on the database type, automatic key generation is implemented using identity/autonumber/auto-increment fields or sequences. If a database doesn’t provide any of these facilities, key values are generated by XPO.

Decorate a key property with the KeyAttribute and pass the attribute’s parameter to specify this property as shown below.

public class Customer : XPBaseObject {
    int oid;
    public int Oid { 
        get { return oid; } 
        set { SetPropertyValue(nameof(Oid), ref oid, value); } 
    // ...
See Also