Пример #1
0
 private static void Migrate(DockingContext context)
 {
     try
     {
         context.Database.Migrate();
     }
     catch {}
 }
Пример #2
0
        public static void Initialize(string connectionString, ILogger logger)
        {
            TryConnect(connectionString, logger);
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseSqlServer(connectionString);
            using (var context = new DockingContext(optionsBuilder.Options))
            {
                Migrate(context);
                Seed(context);
            }
        }
Пример #3
0
 private static void Seed(DockingContext context)
 {
     if (!context.Dockings.Any())
     {
         context.Add(new Docking {
             Bay = "A", ShipName = "Heart of Gold"
         });
         context.Add(new Docking {
             Bay = "B", ShipName = "Hot Black Desiato's Stunt Ship"
         });
         context.SaveChanges();
     }
 }