Exemple #1
0
        public static async Task Initialize(DataProtectionKeysContext dataProtectionKeysContext, ApplicationDbContext applicationDBContext,
                                            IFunctionalService functionalService)
        {
            // Check, if db DataProtectionKeysContext is created
            // Check, if db ApplicationDbContext is created
            await dataProtectionKeysContext.Database.EnsureCreatedAsync();

            await applicationDBContext.Database.EnsureCreatedAsync();


            // Check, if db contains any users. If db is not empty, then db has been already seeded
            if (applicationDBContext.ApplicationUsers.Any())
            {
                return;
            }

            // If empty create Admin User and App User
            await functionalService.CreateDefaultAdminUser();

            await functionalService.CreateDefaultUser();
        }
        public static async Task Initialize(ApplicationDbContext context, QuartzDbContext quartzDbContext, IFunctionalService functional, ILogger logger)
        {
            await context.Database.EnsureCreatedAsync();

            await quartzDbContext.Database.EnsureCreatedAsync();

            // Here we will check, if db contains any users. If db is not empty, then db has been seeded
            if (context.ApplicationUsers.Any())
            {
                return;
            }

            // We want to now create a Super Admin user if Users are not yet created. So they can be managed
            await functional.CreateDefaultAdminUser(logger);

            // We want to now create a App user if Users are not yet created. So they can be managed
            await functional.CreateDefaultAppUser(logger);

            // Populate Plants table
            await functional.CreateDefaultPlants(logger);
        }