public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); var rolesManager = services.GetRequiredService <RoleManager <IdentityRole> >(); await UserAndRoleInitializer.InitializeAsync(userManager, rolesManager); var context = services.GetRequiredService <ApplicationContext>(); EntitiesInitializer.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
private void InitializeEntities() { // Place kits kits = EntitiesInitializer.InitKits(width, height, pointSize); // Place the player player = EntitiesInitializer.InitPlayer(width, height, pointSize, kits.Position); // Create the bombs array var exceptionsNearNotAllowed = new Point[] { player.Position, kits.Position, endPoint }; bombs = EntitiesInitializer.InitBombs(width, height, pointSize, exceptionsNearNotAllowed: exceptionsNearNotAllowed).ToArray(); }