服务.AddDatabaseDeveloperPageExceptionFilter();错误代码:CS1061



代码:

public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<SchoolContext>(options => 
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDatabaseDeveloperPageExceptionFilter();
services.AddControllersWithViews();
}

错误消息:

Error   CS1061  'IServiceCollection' does not contain a definition for 'AddDatabaseDeveloperPageExceptionFilter' 
and no accessible extension method 'AddDatabaseDeveloperPageExceptionFilter' accepting a first argument of type 
'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)   
AspCore_DB  C:Startup.cs   30  Active

这个代码是在MS指南中正式介绍的,我只是遵循了。我正在开发MS Visual Studio 2019 v16.8.2。

经过一些研究,我发现它在Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore库中。

伙计们,您可以从-tools->安装此软件包Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 7.0.10;Nuget包管理器->为解决方案管理Nuget包,这对我有效。

相关内容

最新更新