Middleware: Database error page marked as obsolete
The DatabaseErrorPageMiddleware and its associated extension methods were marked as obsolete in ASP.NET Core 5.0. The middleware and extension methods will be removed in ASP.NET Core 6.0. The functionality will instead be provided by DatabaseDeveloperPageExceptionFilter
and its extension methods.
For discussion, see the GitHub issue at dotnet/aspnetcore#24987.
Version introduced
5.0 RC 1
Old behavior
DatabaseErrorPageMiddleware
and its associated extension methods weren't obsolete.
New behavior
DatabaseErrorPageMiddleware
and its associated extension methods are obsolete.
Reason for change
DatabaseErrorPageMiddleware
was migrated to an extensible API for the developer exception page. For more information on the extensible API, see GitHub issue dotnet/aspnetcore#8536.
Recommended action
Complete the following steps:
Stop using
DatabaseErrorPageMiddleware
in your project. For example, remove theUseDatabaseErrorPage
method call fromStartup.Configure
:public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDatabaseErrorPage(); } }
Add the developer exception page to your project. For example, call the UseDeveloperExceptionPage method in
Startup.Configure
:public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } }
Add the Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore NuGet package to the project file.
Add the database developer page exception filter to the services collection. For example, call the
AddDatabaseDeveloperPageExceptionFilter
method inStartup.ConfigureServices
:public void ConfigureServices(IServiceCollection services) { services.AddDatabaseDeveloperPageExceptionFilter(); }