diff --git a/samples/DatabaseErrorPageSample/Startup.cs b/samples/DatabaseErrorPageSample/Startup.cs index 3419947f5e..1216f94342 100644 --- a/samples/DatabaseErrorPageSample/Startup.cs +++ b/samples/DatabaseErrorPageSample/Startup.cs @@ -11,9 +11,8 @@ namespace DatabaseErrorPageSample { public void ConfigureServices(IServiceCollection services) { - services.AddEntityFramework() - .AddSqlServer() - .AddDbContext(options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=DatabaseErrorPageSample;Trusted_Connection=True;")); + services.AddDbContext( + options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=DatabaseErrorPageSample;Trusted_Connection=True;")); } public void Configure(IApplicationBuilder app) @@ -42,6 +41,11 @@ namespace DatabaseErrorPageSample public class MyContext : DbContext { + public MyContext(DbContextOptions options) + : base(options) + { + } + public DbSet Blog { get; set; } } diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs index 3827af5d85..9e4bee1955 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/DatabaseErrorPageMiddlewareTest.cs @@ -267,7 +267,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests }) .ConfigureServices(services => { - services.AddEntityFramework().AddSqlServer(); + services.AddAddEntityFrameworkSqlServer(); services.AddScoped(); var optionsBuilder = new DbContextOptionsBuilder(); @@ -333,7 +333,7 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests public virtual Task Invoke(HttpContext context) { var options = context.RequestServices.GetService(); - var db = new BloggingContext(context.RequestServices, options); + var db = new BloggingContext(options); db.Blogs.Add(new Blog()); db.SaveChanges(); throw new Exception("SaveChanges should have thrown"); diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContext.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContext.cs index a62c88fd6a..cab6af6b93 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContext.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContext.cs @@ -9,14 +9,10 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests { public class BloggingContext : DbContext { - protected BloggingContext(DbContextOptions options) + public BloggingContext(DbContextOptions options) : base(options) { } - public BloggingContext(IServiceProvider provider, DbContextOptions options) - : base(provider, options) - { } - public DbSet Blogs { get; set; } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithMigrations.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithMigrations.cs index 82a046202f..42ef21ec2e 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithMigrations.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithMigrations.cs @@ -11,14 +11,10 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests { public class BloggingContextWithMigrations : BloggingContext { - protected BloggingContextWithMigrations(DbContextOptions options) + public BloggingContextWithMigrations(DbContextOptions options) : base(options) { } - public BloggingContextWithMigrations(IServiceProvider provider, DbContextOptions options) - : base(provider, options) - { } - // Providing a factory method so that the ctor is hidden from DI public static BloggingContextWithMigrations CreateWithoutExternalServiceProvider(DbContextOptions options) { diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs index 6209544304..b2cc986039 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithPendingModelChanges.cs @@ -10,8 +10,8 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests { public class BloggingContextWithPendingModelChanges : BloggingContext { - public BloggingContextWithPendingModelChanges(IServiceProvider provider, DbContextOptions options) - : base(provider, options) + public BloggingContextWithPendingModelChanges(DbContextOptions options) + : base(options) { } [DbContext(typeof(BloggingContextWithPendingModelChanges))] diff --git a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs index d3488ae580..fb96dfa523 100644 --- a/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs +++ b/test/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.FunctionalTests/TestModels/BloggingContextWithSnapshotThatThrows.cs @@ -11,8 +11,8 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests { public class BloggingContextWithSnapshotThatThrows : BloggingContext { - public BloggingContextWithSnapshotThatThrows(IServiceProvider provider, DbContextOptions options) - : base(provider, options) + public BloggingContextWithSnapshotThatThrows(DbContextOptions options) + : base(options) { } [DbContext(typeof(BloggingContextWithSnapshotThatThrows))]