private static async Task SeedDatabase(DbContextOptions options) { using (var db = new GreetingDbContext(options)) { await db.Greetings.AddAsync(new Greeting { Name = "First Greeting", TimestampUtc = DateTime.Now.ToUniversalTime() }); await db.Greetings.AddAsync(new Greeting { Name = "Second Greeting", TimestampUtc = DateTime.Now.ToUniversalTime() }); await db.SaveChangesAsync(); } }
private static void SeedDatabase(DbContextOptions options) { using (var db = new GreetingDbContext(options)) { db.Greetings.Add(new Greeting { Name = "First Greeting", TimestampUtc = DateTime.Now.ToUniversalTime() }); db.Greetings.Add(new Greeting { Name = "Second Greeting", TimestampUtc = DateTime.Now.ToUniversalTime() }); db.SaveChanges(); } }
private static void RegisterSeriLog(GreetingDbContext db) { var serviceProvider = db.GetInfrastructure(); var loggerFactory = serviceProvider.GetService<ILoggerFactory>(); loggerFactory.AddProvider(new SerilogLoggerProvider()); }
private static void SeedDatabase(DbContextOptions options) { using (var db = new GreetingDbContext(options)) { db.Greetings.Add(new Greeting{Name = "First Greeting", TimestampUtc = DateTime.Now.ToUniversalTime()}); db.Greetings.Add(new Greeting{Name = "Second Greeting", TimestampUtc = DateTime.Now.ToUniversalTime()}); db.SaveChanges(); } }