| 8 | public class DbInitializer |
| 9 | { |
| 10 | public static async Task InitDb(WebApplication app) |
| 11 | { |
| 12 | using var scope = app.Services.CreateScope(); |
| 13 | |
| 14 | var context = scope.ServiceProvider.GetRequiredService<StoreContext>() |
| 15 | ?? throw new InvalidOperationException("Failed to retrieve store context"); |
| 16 | var userManager = scope.ServiceProvider.GetRequiredService<UserManager<User>>() |
| 17 | ?? throw new InvalidOperationException("Failed to retrieve user manager"); |
| 18 | |
| 19 | await SeedData(context, userManager); |
| 20 | } |
| 21 | |
| 22 | private static async Task SeedData(StoreContext context, UserManager<User> userManager) |
| 23 | { |