aspnetcore/breaking-changes/5/middleware-database-error-page-obsolete.md
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.
5.0 RC 1
DatabaseErrorPageMiddleware and its associated extension methods weren't obsolete.
DatabaseErrorPageMiddleware and its associated extension methods are obsolete.
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.
Complete the following steps:
Stop using DatabaseErrorPageMiddleware in your project. For example, remove the UseDatabaseErrorPage method call from Startup.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 xref:Microsoft.AspNetCore.Builder.DeveloperExceptionPageExtensions.UseDeveloperExceptionPage%2A 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 in Startup.ConfigureServices:
public void ConfigureServices(IServiceCollection services)
{
services.AddDatabaseDeveloperPageExceptionFilter();
}