diff --git a/WebAPI/LearningHub.Nhs.Repository/LearningHubDbContext.cs b/WebAPI/LearningHub.Nhs.Repository/LearningHubDbContext.cs
index 82d9903a3..95378502f 100644
--- a/WebAPI/LearningHub.Nhs.Repository/LearningHubDbContext.cs
+++ b/WebAPI/LearningHub.Nhs.Repository/LearningHubDbContext.cs
@@ -40,6 +40,14 @@ public LearningHubDbContext(LearningHubDbContextOptions options)
this.options = options;
}
+ ///
+ /// Gets the Options.
+ ///
+ public LearningHubDbContextOptions Options
+ {
+ get { return this.options; }
+ }
+
///
/// Gets or sets the Address.
///
diff --git a/WebAPI/LearningHub.Nhs.Repository/Resources/BlockCollectionRepository.cs b/WebAPI/LearningHub.Nhs.Repository/Resources/BlockCollectionRepository.cs
index be2bc4f98..332f1a129 100644
--- a/WebAPI/LearningHub.Nhs.Repository/Resources/BlockCollectionRepository.cs
+++ b/WebAPI/LearningHub.Nhs.Repository/Resources/BlockCollectionRepository.cs
@@ -83,7 +83,10 @@ public async Task DeleteBlockCollection(int userId, int blockCollectionId)
foreach (var id in collectionIds)
{
- await this.DbContext.Database.ExecuteSqlRawAsync("resources.BlockCollectionDelete @p0", new SqlParameter("@p0", SqlDbType.Int) { Value = id });
+ using (var lhContext = new LearningHubDbContext(this.DbContext.Options))
+ {
+ _ = lhContext.Database.ExecuteSqlRawAsync("resources.BlockCollectionDelete @p0", new SqlParameter("@p0", SqlDbType.Int) { Value = id });
+ }
}
}