Last active
March 1, 2024 08:13
-
-
Save maliming/6970c79b7bcd5223448bad7a850e0e87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SeedTestDataTestBaseModule : AbpModule | |
{ | |
private static readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1); | |
public override void OnApplicationInitialization(ApplicationInitializationContext context) | |
{ | |
SeedTestData(context); | |
} | |
private static void SeedTestData(ApplicationInitializationContext context) | |
{ | |
using (Semaphore.Lock()) | |
{ | |
AsyncHelper.RunSync(async () => | |
{ | |
using (var scope = context.ServiceProvider.CreateScope()) | |
{ | |
await scope.ServiceProvider | |
.GetRequiredService<IDataSeeder>() | |
.SeedAsync(); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment