-
#code-first
- Code First
- Code First vs Database First
- Column
- Complex Type
- Concurrency Check
- Data Annotations
- Database Generated
- EF6 - Code First from Database!
- EF6 - Code First
- EF6 - Creating Index
- EF6 - Stored Procedure
- Fluent API
- Foreign Key
- Inverse Property
- Key
- Max Length
- Migration
- Min Length
- Not Mapped
- Required
- String Length
- Table
- Timestamp
Entity Framework Timestamp
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; } }