Default Value attribute

API Reference: DefaultValueAttribute Class

The DefaultValueAttribute can be applied to content model properties. The attribute specifies the default value of a property when it is undefined. The default value will only be applied to new content items or newly added properties.

A default value can only be assigned to primitive property types.


Decorate the property with the DefaultValueAttribute. Pass the default value in the constructor. The default value is of type object so the attribute can be used for different property types. In the constructor you will need to provide a value that is of the actual property type. If the default value is not of the correct property type this will cause an invalid configuration error at system startup.

Default Convention

If DefaultValueAttribute is not specified, the default value of the property will be the default value of the type (e.g. default(T)).


public class SampleContent: IContentModel
    // Specifies a default string value.
    [DefaultValue("Enter a description.")]
    public string Description { get; set; }

    // Default value will be 0 by convention.
    public int Count { get; set; }