Fix Unhandled DBErrors in ComponentsWebAssembly and Spa templates (#25466)

* Add workaround for EF issue dotnet/efcore#22341
This commit is contained in:
John Luo 2020-09-01 07:26:33 -07:00 committed by GitHub
parent 748686fa91
commit 222dd67175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View File

@ -38,7 +38,8 @@ namespace Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
{
// Look for DbContext classes registered in the service provider
var registeredContexts = errorContext.HttpContext.RequestServices.GetServices<DbContextOptions>()
.Select(o => o.ContextType);
.Select(o => o.ContextType)
.Distinct(); // Workaround for https://github.com/dotnet/efcore/issues/22341
if (registeredContexts.Any())
{

View File

@ -49,9 +49,9 @@ namespace ComponentsWebAssembly_CSharp.Server
#else
options.UseSqlite(
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDatabaseDeveloperPageExceptionFilter();
#endif
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();

View File

@ -42,9 +42,9 @@ namespace Company.WebApplication1
#else
options.UseSqlite(
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDatabaseDeveloperPageExceptionFilter();
#endif
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();

View File

@ -42,9 +42,9 @@ namespace Company.WebApplication1
#else
options.UseSqlite(
Configuration.GetConnectionString("DefaultConnection")));
#endif
services.AddDatabaseDeveloperPageExceptionFilter();
#endif
services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();