- ABP Framework version: v8.2.1
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
Hello ABP Team,
We are having an issue getting ConcurrencyStamp
updated on the navigational entities of an Aggregate Root. The fields are updated in DB for the navigational entity, however the ConcurrencyStamp
stays unchanged.
At the same time for AggregateRoot
objects the ConcurrencyStamp
is updated without problems in db along with the data.
The navigational entities are of type AuditedEntity
. We added Concurrency Check to them by implementing IHasConcurrencyStamp
interface and adding ConcurrencyStamp
to the class properties
class Party : AuditedEntity<Guid>, IHasConcurrencyStamp
{
...
public virtual string ConcurrencyStamp { get; set; }
}
We ended up overriding HandlePropertiesBeforeSave
of AbpDbContext
as mentioned in issue 19962, which did help:
protected virtual void HandlePropertiesBeforeSave()
{
var entries = ChangeTracker.Entries().ToList();
foreach (var entry in entries)
{
HandleExtraPropertiesOnSave(entry);
if (entry.State.IsIn(EntityState.Modified, EntityState.Deleted))
{
UpdateConcurrencyStamp(entry);
}
}
if (EntityChangeOptions.Value.PublishEntityUpdatedEventWhenNavigationChanges)
{
foreach (var entry in AbpEfCoreNavigationHelper.GetChangedEntityEntries().Where(x => x.State == EntityState.Unchanged))
{
UpdateConcurrencyStamp(entry);
}
}
}
We would like to know if we are missing something in the way we are adding Concurrency Check handling to objects of type AuditedEntity
.
Is overriding HandlePropertiesBeforeSave
method of AbpDbContext
the only solution to get the ConcurrencyStamp
of navigational entities to be refreshed upon updates?