diff --git a/src/SIL.XForge.Scripture/Services/MachineProjectService.cs b/src/SIL.XForge.Scripture/Services/MachineProjectService.cs index ac636f9db0..99e5f608b6 100644 --- a/src/SIL.XForge.Scripture/Services/MachineProjectService.cs +++ b/src/SIL.XForge.Scripture/Services/MachineProjectService.cs @@ -1312,10 +1312,12 @@ CancellationToken cancellationToken } // Remove the corpora and files - foreach ( - (string corpusId, _) in projectSecret.ServalData?.Corpora?.Where(c => c.Value.PreTranslate == preTranslate) - ?? [] - ) + string[] corpusIds = + projectSecret + .ServalData?.Corpora?.Where(c => c.Value.PreTranslate == preTranslate) + .Select(c => c.Key) + .ToArray() ?? []; + foreach (string corpusId in corpusIds) { // Delete the corpus try