Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
 private static void RegisterSeriLog(GreetingDbContext db)
 {
         var serviceProvider = db.GetInfrastructure();
         var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
         loggerFactory.AddProvider(new SerilogLoggerProvider());
 }
Esempio n. 4
-1
 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();
     }
 }