共用方式為


中介軟體:資料庫錯誤頁面已被標示為過時

DatabaseErrorPageMiddleware 及其相關聯的擴充方法在 ASP.NET Core 5.0 中標示為過時。 中間件和擴充方法將會在 Core 6.0 ASP.NET 中移除。 功能會改為由 DatabaseDeveloperPageExceptionFilter 及其擴充方法提供。

如需討論,請參閱 dotnet/aspnetcore#24987 的 GitHub 問題。

推出的版本

5.0 RC 1

舊行為

DatabaseErrorPageMiddleware 及其相關聯的擴充方法尚未過時。

新行為

DatabaseErrorPageMiddleware 及其相關聯的擴充方法已過時。

變更的原因

DatabaseErrorPageMiddleware 已遷移至作為 開發人員例外狀況頁面的可擴展 API。 如需可延伸 API 的詳細資訊,請參閱 GitHub 問題 dotnet/aspnetcore#8536

完成下列步驟:

  1. 停止在您的專案中使用 DatabaseErrorPageMiddleware 。 例如,從 UseDatabaseErrorPage移除 Startup.Configure 方法呼叫:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDatabaseErrorPage();
        }
    }
    
  2. 將開發人員例外狀況頁面新增至您的專案。 例如,請在 UseDeveloperExceptionPage 中呼叫 Startup.Configure 方法:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
    }
    
  3. Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore NuGet 套件新增至項目檔。

  4. 將資料庫開發人員頁面例外狀況篩選新增至服務集合。 例如,請在 AddDatabaseDeveloperPageExceptionFilter 中呼叫 Startup.ConfigureServices 方法:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDatabaseDeveloperPageExceptionFilter();
    }
    

受影響的 API