I have created a .Net Core API and I referenced a .Net framework application to it. The referenced Application connects to a data base and its connection string is stored in
In case you missed it - and because @Zuhair doesn't seem to want to post an answer - here is a copy paste of their solution (I missed this at first as it was only in a comment):
I found the solution. I changed the name of the Web.config to app.config and I was able to get the connection string using:
System.Configuration.ConfigurationManager.ConnectionStrings["SHOPPINGCNN"].ConnectionString
The app.config file looks like this:
encoding="utf-8" ?>
You also need to install this NuGet package:
System.Configuration.ConfigurationManager
In my case I simply renamed the web.config containing the connectionString 'app.config' and it worked.
I realise this probably isn't a good long term solution but for mixed legacy projects - or to get a foot in the door to begin to learn .net Core it's very useful.