Ejemplo n.º 1
0
        // Beispielhaft für Azure Hosting
        private void MigrateAndSeedDatabase(string connectionString)
        {
            var optionsBuilder = new DbContextOptionsBuilder <DataContext>();

            optionsBuilder.UseSqlServer(this.Configuration.GetConnectionString(connectionString));
            using (var db = new DataContext(optionsBuilder.Options))
            {
                db.Database.Migrate();

                AppDataSeed.Init(db);
            }
        }
Ejemplo n.º 2
0
        public void DoIt()
        {
            var connectionString = "Data Source=.\\SQLEXPRESS;Database=Todos;Integrated Security=True;";
            var builder          = new DbContextOptionsBuilder <DataContext>()
                                   .UseSqlServer(connectionString);

            using (var db = new DataContext(builder.Options))
            {
                db.Database.EnsureDeleted();
                db.Database.EnsureCreated();

                AppDataSeed.Init(db);
            }

            Assert.True(true);
        }