I have an application with .net core layered:
data layer, business layer, API
How could I access the connection string from the data layer, if the string is in the appsettings.json file? of the API project
Previously, with the .Net framework, it was done like this: string string = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString
If your main project is the Api project, you can access IConfiguration thanks to Dependency Injection. just define it in the constructor of the class where you need it.
For example