Exemplo n.º 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 userManager = services.GetRequiredService <UserManager <AppUser> >();
                    var context     = services.GetRequiredService <DataContext>();
                    context.Database
                    .Migrate();     //this applies any pending migrations to db and will create db if it doesnt exist
                    Seeds.ActivitesList(context, userManager).Wait();
                }
                catch (Exception e)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(e, "An error occured during migrations");
                }
            }

            host.Run();
        }