diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs index f0f0bbd38..767a3e6cc 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObject.cs @@ -178,22 +178,12 @@ public abstract partial class DomainObject : IAggregate where T : class, IDom if (uncomittedEvents.Count > 0) { - var deletedId = DomainId.Combine(UniqueId, DomainId.Create("deleted")); - var deletedStream = persistenceFactory.WithEventSourcing(GetType(), deletedId, null); + // Use the persisistence with snapshots, because it writes to event store without version check. + var deletedName = DomainId.Combine(UniqueId, DomainId.Create("deleted")); + var deletedStream = persistenceFactory.WithSnapshots(GetType(), deletedName, null); - try - { - // Write to the deleted stream first so we never loose this information. - await deletedStream.WriteEventsAsync(uncomittedEvents, ct); - } - catch (InconsistentStateException) - { - - // There is another deletion event, therefore we have to fetch the version. - await deletedStream.ReadAsync(ct: default); - - await deletedStream.WriteEventsAsync(uncomittedEvents, ct); - } + // Write to the deleted stream first so we never loose this information. + await deletedStream.WriteEventsAsync(uncomittedEvents, ct); } // Cleanup the primary stream second.