Reacting to API changes in EntityFramework

This commit is contained in:
mikary 2014-12-19 10:47:45 -08:00
parent 5e00937d59
commit f76583b18b
3 changed files with 21 additions and 10 deletions

View File

@ -235,7 +235,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{ {
services.AddEntityFramework().AddSqlServer(); services.AddEntityFramework().AddSqlServer();
services.AddScoped<BloggingContextWithMigrations>(); services.AddScoped<BloggingContextWithMigrations>();
services.AddInstance<DbContextOptions>(new DbContextOptions().UseSqlServer(database.ConnectionString));
var contextOptions = new DbContextOptions();
contextOptions.UseSqlServer(database.ConnectionString);
services.AddInstance<DbContextOptions>(contextOptions);
}); });
var options = DatabaseErrorPageOptions.ShowAll; var options = DatabaseErrorPageOptions.ShowAll;
@ -268,9 +271,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
services.AddEntityFramework() services.AddEntityFramework()
.AddSqlServer(); .AddSqlServer();
services.AddInstance<DbContextOptions>( var options = new DbContextOptions();
new DbContextOptions() options.UseSqlServer(database.ConnectionString);
.UseSqlServer(database.ConnectionString));
services.AddInstance<DbContextOptions>(options);
}); });
app.UseDatabaseErrorPage(); app.UseDatabaseErrorPage();
@ -386,9 +390,11 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
.AddSqlServer(); .AddSqlServer();
services.AddScoped<TContext>(); services.AddScoped<TContext>();
services.AddInstance<DbContextOptions>(
new DbContextOptions() var options = new DbContextOptions();
.UseSqlServer(database.ConnectionString)); options.UseSqlServer(database.ConnectionString);
services.AddInstance<DbContextOptions>(options);
}); });
app.UseDatabaseErrorPage(); app.UseDatabaseErrorPage();

View File

@ -65,7 +65,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{ {
using (var database = SqlServerTestStore.CreateScratch()) using (var database = SqlServerTestStore.CreateScratch())
{ {
var options = new DbContextOptions().UseSqlServer(database.ConnectionString); var options = new DbContextOptions();
options.UseSqlServer(database.ConnectionString);
var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath; var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath;
TestServer server = TestServer.Create(app => TestServer server = TestServer.Create(app =>
@ -183,7 +184,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{ {
using (var database = SqlServerTestStore.CreateScratch()) using (var database = SqlServerTestStore.CreateScratch())
{ {
var options = new DbContextOptions().UseSqlServer(database.ConnectionString); var options = new DbContextOptions();
options.UseSqlServer(database.ConnectionString);
TestServer server = TestServer.Create(app => TestServer server = TestServer.Create(app =>
{ {

View File

@ -40,7 +40,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
private void EnsureDeleted() private void EnsureDeleted()
{ {
using (var db = new DbContext(new DbContextOptions().UseSqlServer(_connectionString))) var options = new DbContextOptions();
options.UseSqlServer(_connectionString);
using (var db = new DbContext(options))
{ {
db.Database.EnsureDeleted(); db.Database.EnsureDeleted();
} }