List of available data annotations
In the following namespace: System.ComponentModel.DataAnnotations, there are the following annotations available:
- KeyAttribute
- StringLengthAttribute
- MaxLengthAttribute
- ConcurrencyCheckAttribute
- RequiredAttribute
- TimestampAttribute
- ComplexTypeAttribute
- ColumnAttribute
- Placed on a property to specify the column name, ordinal
- TableAttribute
- Placed on a class to specify the table name and schema
- InversePropertyAttribute
- Placed on a navigation property to specify the property that represents the other end of a relationship
- ForeignKeyAttribute
- Placed on a navigation property to specify the property that represents the foreign key of the relationship
- DatabaseGeneratedAttribute
- Placed on a property to specify how the database generates a value for the property (Identity, Computed or None)
- NotMappedAttribut
- Placed on a property or class to exclude it from the database
It's nice to know that using this attributes is allso influences the database.
A field with a MaxLentAttribute will become a nvarchar max field.
A field with a MaxLentAttribute wich specifies 4 will become a nvarchar(4) field in the database.
Entity object attributes
Next to data anotations for the properties of the Entity Object class there are a few attributes available for the Entity Object
- Serialize atrribute
- If you need to serialize the Entity object it needs to be decorated with the Serialize attributed.
- DataContractAttribute
- If yo want to pass the Entiry object through a WCF service you entity object needs to be decorated with the DataContractAttribute