KEMBAR78
IsRowVersion or [Timestamp] on property that maps to provider byte[] type should generate rowversion column · Issue #12434 · dotnet/efcore · GitHub
Skip to content

IsRowVersion or [Timestamp] on property that maps to provider byte[] type should generate rowversion column #12434

@ajcvickers

Description

@ajcvickers

As described in #5936, mapping a ulong with a store type of "rowversion" (or "timestamp") results in a rowversion column in SQL Server that can be used effectively in LINQ queries. This should also work for cases like this:

public class Blog
{
    public int Id { get; set; }
    public ulong RowVersion { get; set; }
}

modelBuilder
    .Entity<Blog>()
    .Property(e => e.RowVersion)
    .HasConversion<byte[]>()
    .IsRowVersion();

and this:

public class Blog
{
    public int Id { get; set; }

    [Timestamp]
    public ulong RowVersion { get; set; }
}

modelBuilder
    .Entity<Blog>()
    .Property(e => e.RowVersion)
    .HasConversion<byte[]>();

And possibly even when .HasConversion<byte[]>() is not used explicitly, since IsRowVersion or [Timestamp] imply this, at least for SQL Server

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions