In the following namespace: System.ComponentModel.DataAnnotations, there are the following annotations available:
- Placed on a property to specify the column name, ordinal
- Placed on a class to specify the table name and schema
- Placed on a navigation property to specify the property that represents the other end of a relationship
- Placed on a navigation property to specify the property that represents the foreign key of the relationship
- Placed on a property to specify how the database generates a value for the property (Identity, Computed or None)
- 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.
- If yo want to pass the Entiry object through a WCF service you entity object needs to be decorated with the DataContractAttribute