Api/Berizco.Repository/RepositoryConfig.cs

20 lines
680 B
C#
Raw Normal View History

2023-09-15 12:37:02 +03:30
using Microsoft.AspNetCore.Builder;
using Task = System.Threading.Tasks.Task;
namespace Brizco.Repository;
public static class RepositoryConfig
2023-09-08 12:25:21 +03:30
{
2023-09-15 12:37:02 +03:30
public static async Task InitialDb(this IApplicationBuilder app)
2023-09-08 12:25:21 +03:30
{
2023-09-15 12:37:02 +03:30
var scopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();
using (var scope = scopeFactory.CreateScope())
{
var identityDbInitialize = scope.ServiceProvider.GetService<IDbInitializerService>();
if (identityDbInitialize != null)
{
identityDbInitialize.Initialize();
await identityDbInitialize.SeedDate();
}
}
2023-09-08 12:25:21 +03:30
}
}