Beispiel #1
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var context = services.GetRequiredService <OasisContext>();
                    context.Database.Migrate();
                    OASeedData.Initialize(services);
                    //OAScriptSeedData.Initialize(services);

                    var identityContext = services.GetRequiredService <ApplicationDbContext>();
                    identityContext.Database.Migrate();
                    IdentitySeedData.SeedAsync(identityContext, services).Wait();
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
        public async Task <Unit> Handle(SeedIdentityCommand request, CancellationToken cancellationToken)
        {
            await IdentitySeedData.SeedAsync(_userManager, _roleManager);

            return(Unit.Value);
        }
 public static void InitializeIdentityUserForTests(UserManager <ApplicationUser> userManager,
                                                   RoleManager <ApplicationRole> roleManager)
 {
     IdentitySeedData.SeedAsync(userManager, roleManager).Wait();
 }