diff --git a/src/Marten/HostExtensions.cs b/src/Marten/HostExtensions.cs index 0001a3a4cf..780d997125 100644 --- a/src/Marten/HostExtensions.cs +++ b/src/Marten/HostExtensions.cs @@ -82,10 +82,21 @@ public static async Task CleanAllMartenDataAsync(this IHost host) where T : I /// Call DocumentStore.ResetAllData() on the document store in this host /// /// - public static Task ResetAllMartenDataAsync(this IHost host) + public static async Task ResetAllMartenDataAsync(this IHost host) { + var coordinator = host.Services.GetService(); + if (coordinator != null) + { + await coordinator.PauseAsync().ConfigureAwait(false); + } + var store = host.DocumentStore(); - return store.Advanced.ResetAllData(CancellationToken.None); + await store.Advanced.ResetAllData(CancellationToken.None).ConfigureAwait(false); + + if (coordinator != null) + { + await coordinator.ResumeAsync().ConfigureAwait(false); + } } /// @@ -93,9 +104,20 @@ public static Task ResetAllMartenDataAsync(this IHost host) /// /// /// - public static Task ResetAllMartenDataAsync(this IHost host) where T : IDocumentStore + public static async Task ResetAllMartenDataAsync(this IHost host) where T : IDocumentStore { + var coordinator = host.Services.GetService>(); + if (coordinator != null) + { + await coordinator.PauseAsync().ConfigureAwait(false); + } + var store = host.DocumentStore(); - return store.Advanced.ResetAllData(CancellationToken.None); + await store.Advanced.ResetAllData(CancellationToken.None).ConfigureAwait(false); + + if (coordinator != null) + { + await coordinator.ResumeAsync().ConfigureAwait(false); + } } }