Пример #1
0
        private static void EnsureDatabaseIsCreatedAndSeeded(DbContextOptions <AppDataContext> options, bool seedDatabase, bool deleteDatabase)
        {
            using (var context = new AppDataContext(options))
            {
                if (deleteDatabase)
                {
                    context.Database.EnsureDeleted();
                }

                if (context.Database.EnsureCreated() && seedDatabase)
                {
                    context.SeedDatabase();
                }
            }
        }