I have .netcore 3.1
application and I want to update it to .net 5.0
I have the following code
public static IAppSettings ConfigureAppSettings(this IServiceCollection services, IConfiguration configuration)
{
void ConfigureSection<Interface, Implementation>(string sectionName)
where Implementation : Interface, new() where Interface : class
{
Implementation configSection = new Implementation();
configuration.GetSection(sectionName).Bind(configSection);
services.AddSingleton<Interface>(configSection);
}
}
it was working previously, but after updating to .NET 5 I start seeing this compile-time error
CS1061 'IConfigurationSection' does not contain a definition for 'Bind' and no accessible extension method 'Bind' accepting a first argument of type 'IConfigurationSection' could be found (are you missing a using directive or an assembly reference?)
- Is the
Bind
method been removed? - There is no mention for the solution to this problem in the official documentation for the migration
My question: What is the alternative to the Bind
method?