From 4d1262c39b0956d0fc19371d841b2b46fe7467b9 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Mon, 10 Jun 2019 14:28:28 -0700 Subject: [PATCH] Small fixes for DatabaseErrorPageMiddleware The main change here is to also allow public `HasTables` to be found. This will be removed once we get the new EF merged. The change to the migration makes it align with what we would generate, but I don't think has any functional impact on the tests. See also https://github.com/aspnet/EntityFrameworkCore/pull/16024 which (I really hope!)fixes the other failures once it makes it here. --- .../src/DatabaseErrorPageMiddleware.cs | 2 +- .../FunctionalTests/TestModels/BloggingContextWithMigrations.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Middleware/Diagnostics.EntityFrameworkCore/src/DatabaseErrorPageMiddleware.cs b/src/Middleware/Diagnostics.EntityFrameworkCore/src/DatabaseErrorPageMiddleware.cs index 96ebb8a1f4cc..acbc43ae1d56 100644 --- a/src/Middleware/Diagnostics.EntityFrameworkCore/src/DatabaseErrorPageMiddleware.cs +++ b/src/Middleware/Diagnostics.EntityFrameworkCore/src/DatabaseErrorPageMiddleware.cs @@ -135,7 +135,7 @@ public virtual async Task Invoke(HttpContext httpContext) if (databaseExists) { // Also check if the database is completely empty - see https://github.com/aspnet/EntityFrameworkCore/issues/15997 - databaseExists = (bool)typeof(RelationalDatabaseCreator).GetMethod("HasTables", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(relationalDatabaseCreator, null); + databaseExists = (bool)typeof(RelationalDatabaseCreator).GetMethod("HasTables", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Invoke(relationalDatabaseCreator, null); } var migrationsAssembly = context.GetService(); diff --git a/src/Middleware/Diagnostics.EntityFrameworkCore/test/FunctionalTests/TestModels/BloggingContextWithMigrations.cs b/src/Middleware/Diagnostics.EntityFrameworkCore/test/FunctionalTests/TestModels/BloggingContextWithMigrations.cs index 1f3204157a09..f4ee82c93895 100644 --- a/src/Middleware/Diagnostics.EntityFrameworkCore/test/FunctionalTests/TestModels/BloggingContextWithMigrations.cs +++ b/src/Middleware/Diagnostics.EntityFrameworkCore/test/FunctionalTests/TestModels/BloggingContextWithMigrations.cs @@ -28,7 +28,7 @@ protected override void BuildModel(ModelBuilder builder) { builder.Entity("Blogging.Models.Blog", b => { - b.Property("BlogId"); + b.Property("BlogId").ValueGeneratedOnAdd(); b.Property("Name"); b.HasKey("BlogId"); });