// 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); } }
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); }