Row Version Property

View Entity Row Version Property Configuration Options

Row Versioning for Concurrency Control

The AddRowVersion method enables support for optimistic concurrency control by adding a special hidden property to your entity โ€” typically called RowVersion.

This property is used to detect whether a record has been modified by someone else between the time it was read and the time it was saved. It is especially important in multi-user applications, where multiple people might try to update the same record at the same time.

designer.Properties.AddRowVersion();

How It Works

  • The framework automatically defines a byte[] property on the entity (usually named RowVersion).
  • The database automatically updates this value every time the record changes.
  • When you try to update a record, the framework checks if the RowVersion has changed since the data was loaded.
  • If the version does not match, the update is rejected to avoid overwriting someone else's changes.

When to Use Row Versioning

You should use AddRowVersion if your application allows users to edit shared data โ€” especially in collaborative environments such as:

  • Admin dashboards
  • Back-office systems
  • Multi-user editing workflows

It is a simple but powerful mechanism to avoid conflicts without needing to lock records or build complex merge logic.

Why It's Important

  • Prevents users from unintentionally overwriting each otherโ€™s changes.
  • Improves data integrity in environments with frequent updates.
  • Provides a clear error path when a concurrency conflict is detected (which you can handle with user-friendly messages).

There is no need to render this field in the UI โ€” the framework manages it automatically behind the scenes. It is only used during save operations to ensure the data has not changed unexpectedly.

publicpartialclassEmployee:IBkEntity<Employee,ApplicationDbContext>

{

    publicvoidBkConfiguration(IBkEntityDesigner<Employee,ApplicationDbContext>designer)

    {

        designer.Properties.AddRowVersion();

// ... other properties    }

}

An unhandled error has occurred. Reload ๐Ÿ—™