-
#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
30% OFF - 10th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY10
Entity Framework Timestamp Data Annotation
The TimeStamp
attribute is used to creates a column with timestamp data type in the SQL Server database.
- EF Code first will treat
Timestamp
properties 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
Timestamp
column in concurrency check on theUPDATE
statement 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