-
#code-first
- Code First
- Code First vs Database First
- Column Data Annotations
- ComplexType Data Annotations
- ConcurrencyCheck Data Annotations
- Data Annotations
- DatabaseGenerated Data Annotations
- Fluent API
- ForeignKey Data Annotations
- InverseProperty Data Annotations
- Key Data Annotation
- MaxLength Data Annotation
- Migration
- MinLength Data Annotation
- NotMapped Data Annotation
- Required Data Annotation
- StringLength Data Annotation
- Table Data Annotation
- Timestamp Data Annotation
- How to Create Index in Database with Entity Framework Code First
- How to Reverse Engineer Tables and Views with EF Code First
- Meta title: How to use Stored Procedures with Entity Framework Code First
- Using Entity Framework Code First to map POCO classes to the database
Entity Framework Timestamp Data Annotation
The TimeStamp attribute is used to create a column with timestamp data type in the SQL Server database.
- EF Code First will treat
Timestampproperties the same as ConcurrencyCheck properties. - It can only be applied once in an entity class to a byte array type property.
- It will also ensure that the database field that Code First generates is non-nullable.
- Entity Framework API automatically uses this
Timestampcolumn in concurrency check on theUPDATEstatement in the database.
In the following example, the Timestamp attribute is applied to the RowVersion property which is a byte array.
public class Book { public int BookId { get; set; } public string Title { get; set; } [Timestamp] public byte[] RowVersion { get; set; } }
Author: ZZZ Projects