Пример #1
0
        protected static async Task SeedDb(DbContextOptions <MiniURLDbContext> dbOptions, IDateTime dateTime)
        {
            using (var ctx = new MiniURLDbContext(dbOptions, dateTime))
            {
                var seeder = new MiniURLDbContextSeeder(ctx);

                try
                {
                    await seeder.SeedAllAsync(new System.Threading.CancellationToken());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #2
0
        private async static Task SeedDb(IHost host)
        {
            using var scope = host.Services.CreateScope();
            var services = scope.ServiceProvider;
            var ctx      = services.GetRequiredService <IMiniURLDbContext>();

            var seeder = new MiniURLDbContextSeeder(ctx);

            try
            {
                await seeder.SeedAllAsync(new System.Threading.CancellationToken());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }