Summary
A byte[] property configured with IsRowVersion() or [Timestamp] (the shape used with SQL Server rowversion) is accepted but never changed. Its value in the update filter therefore always matches, and a stale SaveChanges succeeds instead of throwing DbUpdateConcurrencyException. The provider only generates row versions for a non-nullable int, uint, long or ulong; a row version of any other type (int?, Guid, an enum, ...) is silently inert in the same way.
Fix
- Generate byte[] row versions: an 8-byte big-endian unsigned counter, the same counter as a ulong row version, stored as binary in _version. An empty or null value counts as 0 (the first write stores 1). A length other than 0 or 8 throws InvalidOperationException during SaveChanges, before anything is written. A counter at its maximum throws OverflowException.
- A ulong row version converted to byte[] (.IsRowVersion().HasConversion<byte[]>()) already works and stores the same 8 bytes.
- The model validator rejects a row version of any other type with NotSupportedException, naming the property and the supported types. EF models a row version as a concurrency token with ValueGenerated.OnAddOrUpdate, so a token configured that way with an unsupported type is rejected too. A plain IsConcurrencyToken() / [ConcurrencyCheck] is unaffected.
- A byte[] row version continues from the replaced document's when an entity is removed and another added with the same key (EF-490).
This is a breaking change (entry in BREAKING-CHANGES.md): a byte[] row version moves to the _version element and existing documents are not migrated, an application-assigned byte[] of another length now throws, and an unsupported row version type now fails model validation.
Ported from ajcvickers/mongo-efcore-provider#112 (fork issue #105).