Since there is no ConfigurationManager class in .NET Core, now I need to set config in appsettings.json instead of web.config
According to this on the blog, I have to set my configuration there, so I liked it:
{ "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, "Conexion": { "name" : "empresas", "connectionString": "Data Source=empresas;Initial Catalog=CATALMA; Integrated Security=True;", "providerName": "System.Data.SqlClient" } }
I just wrote this "Conexion".
Now I created the following class in the ViewModels folder:
public class ConexionConfig { public string name { get; set; } public string connectionString { get; set; } public string providerName { get; set; } }
Now, in Startup.cs, in the ConfigureServices method, I have to add it:
public void ConfigureServices(IServiceCollection services) {
But unfortunately, I get the following error:
Argument 2: cannot convert from 'Microsoft.Extensions.Configuration.IConfigurationSection' to 'System.Action<ConexionConfig>'
What am I missing?
Mr_LinDowsMac
source share