I reproduced a way to access the database with .net Framework but it doesn't work in .net Core. I found a way to fix it and followed what was said but I get the error that the connectionString is not initialized. Therefore, I don't know how to get it working.
Code I'm using:
public class DataAccess
{
    private string _connectionString;
    public DataAccess(string connectionString)
    {
        _connectionString = connectionString;
    }
    public List<PropertyModel> LoadData()
    {
        var data = new List<PropertyModel>();
        using(IDbConnection cnn = new SqlConnection(_connectionString))
        {
            data = cnn.Query<PropertyModel>(@"select *
                        from dbo.PropertyModel;").ToList();
        }
        return data;
    }
}
In Controller:
private DataAccess data;
    public PropertyController(IOptions<ConnectionConfig> connectionConfig)
    {
        var connection = connectionConfig.Value;
        string connectionString = connection.Analysis;
        data = new DataAccess(connectionString);
    }
    public IActionResult Index()
    {
        var test = data.LoadData();
        return View();
    }
In StartUp:
 services.Configure<ConnectionConfig
(Configuration.GetSection("MVCCoreAppDB"));
And I created a POCO class:
public class ConnectionConfig
{
    public string Analysis { get; set; }
}
I followed this.
appsettings.json:
"ConnectionStrings": {
"MVCCoreAppDB": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MVCCoreAppDB;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"},
 
    