Properties
Models in a Coalesce application are just EF Core POCOs. The properties defined on your models should fit within the constraints of EF Core.
Coalesce currently has a few more restrictions than what EF Core allows, but hopefully over time some of these restrictions can be relaxed as Coalesce grows in capability.
Property Varieties
The following kinds of properties may be declared on your models.
Primitives, Scalars, & Dates
Most common built-in primitive and scalar data types (numerics, strings, booleans, enums, DateTime
, DateTimeOffset
), and their nullable variants, are all supported as model properties. Collections of these types are also supported.
Non-mapped POCOs
Properties of a type that are not on your DbContext
will also have corresponding properties generated on the TypeScript ViewModels typed as Plain Models, and the values of such properties will be sent with the object to the client when requested. Properties of this type will also be sent back to the server by the client when they are encountered.
See External Types for more information.
Getter-only Properties
Any property that only has a getter will also have a corresponding property generated in the TypeScript ViewModels and will receive values of the property from the server, but values won't be sent back to the server.
If such a property is defined as an auto-property, the [NotMapped]
attribute should be used to prevent EF Core from attempting to map such a property to your database.
Init-only Properties
Properties on CRUD Models that use an init
accessor rather than a set
accessor will be implicitly treated as required, and can also only have a value provided when the entity is created for the first time. Any values provided during save actions for init-only properties when updating an existing entity will be ignored.
Property Customization
For any of the kinds of properties outlined above, the following customizations can be applied:
Attributes
Coalesce provides a number of Attributes, and supports a number of other .NET attributes, that allow for further customization of your model.
Security
Property values received by the server from the client will be ignored if rejected by any property-level Security. This security is implemented in the Generated C# DTOs.
Loading & Serialization
The Default Loading Behavior, any custom functionality defined in Data Sources, and [DtoIncludes] & [DtoExcludes] may also restrict which properties are sent to the client when requested.