Throw a better exception message when concurrency token is an array
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
Use the supplied SQL Server RowVersion reproduction as the starting point; compare assigning a new byte array with mutating the tracked array, and verify behavior against the InMemory provider. Done should be defined by the intended concurrency failure and exception message, but the issue does not name files or tests.
Written by the indexing model from the issue text.
Description
Concurrency check doesn't work when using RowVersion (SQL Server's timestamp) and one creates a new instance of byte array, instead of updating existing.
Happens when using SQL Server store, but not with InMemory. See code below.
Steps to reproduce
// entity
public class Party
{
public int Id { get; set; }
public string FirstName { get; set; }
public byte[] RowVersion { get; set; }
}
// mapping excerpt
modelBuilder.Entity<Party>(entity =>
{
entity.ToTable("party");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.FirstName)
.HasColumnName("first_name")
.HasMaxLength(255);
entity.Property(e => e.RowVersion) // maps to timestamp SQL server type
.IsRequired()
.HasColumnName("row_version")
.IsRowVersion();
}
// this code doesn't raise an exception at all
var party = db.Party.First();
party.RowVersion = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
db.Update(party);
db.SaveChanges(); // <- error, no exception is thrown
// this code correctly raises a concurrency exception
var party = db.Party.First();
party.RowVersion[0] = 99;
db.Update(party);
db.SaveChanges(); // throws dbconcurrencyexception
Further technical details
EF Core version: 3.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer (works correctly with InMemory)
Target framework: .NET Core 3.0
Operating system: Windows 10
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100