Hi @Eligio Morgado ,
In the BaseModel constructor method, you can refer the following code to create a configuration instance:
public class BaseModel
{
private readonly IConfiguration _config;
public BaseModel()
{
_config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
}
public string Name { get; set; }
public string GetConnection()
{
return _config.GetConnectionString("DefaultConnection");
}
}
Then, the result is like this:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion