dotnet core+mongodb 开发 web api
資深大佬 : zxCoder 3
根据官网这个教程 https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/first-mongo-app
结果在配置数据库部分出错了
教程的代码:
public void ConfigureServices(IServiceCollection services) { // requires using Microsoft.Extensions.Options services.Configure<BookstoreDatabaseSettings>( Configuration.GetSection(nameof(BookstoreDatabaseSettings))); services.AddSingleton<IBookstoreDatabaseSettings>(sp => sp.GetRequiredService<IOptions<BookstoreDatabaseSettings>>().Value); services.AddControllers(); }
本地在 Configuration.GetSection()报错,Cannot access non-static method ‘GetSection’ in static context
网上没找到同样的错误,是我哪一步做错了吗
大佬有話說 (8)