Skip to content

Attributes

Coalesce provides a number of C# attributes that can be used to decorate your model classes and their properties in order to customize behavior, appearance, security, and more. Coalesce also supports a number of annotations from System.ComponentModel.DataAnnotations.

Coalesce Attributes

Browse the list in the sidebar to learn about the attributes that Coalesce provides that can be used to decorate your models.

ComponentModel Attributes

Coalesce also supports a number of the built-in System.ComponentModel.DataAnnotations attributes and will use these to shape the generated code.

[Display]

The displayed name and description of a property, as well as the order in which it appears in generated views, can be set via the [Display] attribute. By default, properties will be displayed in the order in which they are defined in their class.

[DisplayName]

The displayed name of a property can also be set via the [DisplayName] attribute.

[Description]

The description of a type or member, such as a class, property, method, or parameter.

[Required]

Properties with [Required] will generate client validation and server validation rules.

[Range]

Properties with [Range] will generate client validation and server validation rules.

[MinLength]

Properties with [MinLength] will generate client validation and server validation rules.

[MaxLength]

Properties with [MaxLength] will generate client validation and server validation rules.

[DataType]

Some values of DataType when provided to DataTypeAttribute on a string property will alter the behavior of the Vue Components. See c-display and c-input for details.

[ForeignKey]

Normally, Coalesce figures out which properties are foreign keys, but if you don't use standard EF naming conventions then you'll need to annotate with [ForeignKey] to help out both EF and Coalesce. See the Entity Framework Relationships documentation for more.

[InverseProperty]

Sometimes, Coalesce (and EF, too) can have trouble figuring out what the foreign key is supposed to be for a collection navigation property. See the Entity Framework Relationships documentation for details on how and why to use [InverseProperty].

[DatabaseGenerated]

Primary Keys with [DatabaseGenerated(DatabaseGeneratedOption.None)] will be settable on the client and will be appropriately handled by the Standard Behaviors on the server.

[NotMapped]

Model properties that aren't mapped to the database should be marked with [NotMapped] so that Coalesce doesn't try to load them from the database when searching or carrying out the Default Loading Behavior.

[DefaultValue]

Properties with [DefaultValue] will receive the specified value when a new ViewModel is instantiated on the client. This enables scenarios like pre-filling a required property with a suggested value.


Coalesce is a free and open-source framework created by IntelliTect to fill our desire to create better apps, faster. IntelliTect is a high-end software architecture and development consulting firm based in Spokane, Washington.

If you're looking for help with your software project, whether it be a Coalesce application, other technologies, or even just an idea, reach out to us at info@intellitect.com — we'd love to start a conversation! Our clients range from Fortune 100 companies to local small businesses and non-profits.