Update to use DbContextOptionsBuilder
This commit is contained in:
parent
917b9e9c2e
commit
f4c05c8b09
|
|
@ -236,9 +236,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
services.AddEntityFramework().AddSqlServer();
|
services.AddEntityFramework().AddSqlServer();
|
||||||
services.AddScoped<BloggingContextWithMigrations>();
|
services.AddScoped<BloggingContextWithMigrations>();
|
||||||
|
|
||||||
var contextOptions = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
contextOptions.UseSqlServer(database.ConnectionString);
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
services.AddInstance<DbContextOptions>(contextOptions);
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
});
|
});
|
||||||
|
|
||||||
var options = DatabaseErrorPageOptions.ShowAll;
|
var options = DatabaseErrorPageOptions.ShowAll;
|
||||||
|
|
@ -271,10 +271,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
services.AddEntityFramework()
|
services.AddEntityFramework()
|
||||||
.AddSqlServer();
|
.AddSqlServer();
|
||||||
|
|
||||||
var options = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
options.UseSqlServer(database.ConnectionString);
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
services.AddInstance<DbContextOptions>(options);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseDatabaseErrorPage();
|
app.UseDatabaseErrorPage();
|
||||||
|
|
@ -391,10 +390,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
|
|
||||||
services.AddScoped<TContext>();
|
services.AddScoped<TContext>();
|
||||||
|
|
||||||
var options = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
options.UseSqlServer(database.ConnectionString);
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
services.AddInstance<DbContextOptions>(options);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseDatabaseErrorPage();
|
app.UseDatabaseErrorPage();
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,9 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
using (var database = SqlServerTestStore.CreateScratch())
|
using (var database = SqlServerTestStore.CreateScratch())
|
||||||
{
|
{
|
||||||
var options = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
options.UseSqlServer(database.ConnectionString);
|
optionsBuilder.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 =>
|
||||||
|
|
@ -74,7 +75,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
services.AddEntityFramework().AddSqlServer();
|
services.AddEntityFramework().AddSqlServer();
|
||||||
services.AddScoped<BloggingContextWithMigrations>();
|
services.AddScoped<BloggingContextWithMigrations>();
|
||||||
services.AddInstance<DbContextOptions>(options);
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (useCustomPath)
|
if (useCustomPath)
|
||||||
|
|
@ -182,8 +183,8 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
using (var database = SqlServerTestStore.CreateScratch())
|
using (var database = SqlServerTestStore.CreateScratch())
|
||||||
{
|
{
|
||||||
var options = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
options.UseSqlServer(database.ConnectionString);
|
optionsBuilder.UseSqlServer(database.ConnectionString);
|
||||||
|
|
||||||
TestServer server = TestServer.Create(app =>
|
TestServer server = TestServer.Create(app =>
|
||||||
{
|
{
|
||||||
|
|
@ -191,7 +192,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
{
|
{
|
||||||
services.AddEntityFramework().AddSqlServer();
|
services.AddEntityFramework().AddSqlServer();
|
||||||
services.AddScoped<BloggingContextWithSnapshotThatThrows>();
|
services.AddScoped<BloggingContextWithSnapshotThatThrows>();
|
||||||
services.AddInstance<DbContextOptions>(options);
|
services.AddInstance<DbContextOptions>(optionsBuilder.Options);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseMigrationsEndPoint();
|
app.UseMigrationsEndPoint();
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
|
||||||
|
|
||||||
private void EnsureDeleted()
|
private void EnsureDeleted()
|
||||||
{
|
{
|
||||||
var options = new DbContextOptions();
|
var optionsBuilder = new DbContextOptionsBuilder();
|
||||||
options.UseSqlServer(_connectionString);
|
optionsBuilder.UseSqlServer(_connectionString);
|
||||||
|
|
||||||
using (var db = new DbContext(options))
|
using (var db = new DbContext(optionsBuilder.Options))
|
||||||
{
|
{
|
||||||
db.Database.EnsureDeleted();
|
db.Database.EnsureDeleted();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue