30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

EF Core TimeStamp Attribute

The TimeStamp attribute is used to specify that a property should take part in concurrency management.

The TimeStamp attribute is only valid if applied to a property that is a byte array. How this is implemented is dependent on the current database provider. In SQL Server, this will map to a rowversion type.

public class Author
    public int AuthorId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public ICollection<Book> Books { get; set; }
    public byte[] RowVersion { get; set; }

Fluent API

The Fluent API equivalent to the TimeStamp attribute is the IsConcurrencyToken method chained with the ValueGeneratedOnAddOrUpdate method.

From version 1.1 of EF Core, The IsRowVersion method will also be available which acts as a convenience wrapper for the chained combination described above.

Further Reading

Date Modified: 2023-02-28

Edit this page in GitHub

Got any EF Core Question?