diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizer.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizer.cs index df8806d9d7..27260bcee7 100644 --- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizer.cs +++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizer.cs @@ -114,8 +114,11 @@ public abstract class ExternalEntitySynchronizer : } else { + // The version will auto-increment by one when the repository updates the entity. + var entityVersion = eto.EntityVersion - 1; + await MapToEntityAsync(eto, localEntity); - ObjectHelper.TrySetProperty(localEntity, x => x.EntityVersion, () => eto.EntityVersion); + ObjectHelper.TrySetProperty(localEntity, x => x.EntityVersion, () => entityVersion); await _repository.UpdateAsync(localEntity, true); } diff --git a/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizers/ExternalEntitySynchronizer_Tests.cs b/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizers/ExternalEntitySynchronizer_Tests.cs index e0b86c82ea..c32ea0e513 100644 --- a/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizers/ExternalEntitySynchronizer_Tests.cs +++ b/framework/test/Volo.Abp.Ddd.Tests/Volo/Abp/Domain/Entities/Events/Distributed/ExternalEntitySynchronizers/ExternalEntitySynchronizer_Tests.cs @@ -60,7 +60,7 @@ public class ExternalEntitySynchronizer_Tests : AbpIntegratedTest