The Fluent API IsRowVersion Method

The IsRowVersion method is used to denote that a property should take part in concurrency management.

When applied to a byte array property, the IsRowVersion method denotes that the property should map to a database type that provides automatic row-versioning, such as the SQL Server rowversion type:

public class SampleContext : DbContext
    public DbSet<Author> Authors { get; set; }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
            .Property(a => a.RowVersion)

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

The IsRowVersion method was introduced in EF Core 1.1 as a wrapper around the IsConcurrencyToken method chained with the ValueGeneratedOnAddOrUpdate method.

Data Annotations

The Data Annotations equivalent to the IsRowVersion method is the Timestamp attribute.

Further Reading

Last updated: 14/03/2017 16:33:44
Proficiency Level: Beginner