Key attribute

API Reference: KeyAttribute Class

The KeyAttribute can be applied to page models, sections, content models, and content properties. The attribute specifies the unique key of the object for data storage.

Usage

Decorate the model class or property with the KeyAttribute. Pass the key in the attribute constructor.

Default Convention

If KeyAttribute is not specified, the object identifier will be used as unique key.

Example

[DisplaKeyyName("RSSFeed")]
public class RssFeed: IPageModel
{
    [Key("SeoContent")]
    public SeoContent Seo { get; set; }

    // Key will be 'MyNamespace.RssFeed.SecondParagraph' by convention
    public ParagraphContent SecondParagraph { get; set; }
}