I have a ASP.NET Core Web API project added to my solution. It uses a project dependency which connects to SQL Server database, using a connection string like this:
public string connectionString = ConfigurationManager.ConnectionStrings["ConnectionName"].ConnectionString;
This works fine, another Web/WinForm Apps uses this library and connects to SQL Server instance (the connection string is set in the web.config or app.config)
The problem:
The ASP.NET Core Web API project fails to use the connection string from the library, I have set appsetting.json:
"ConnectionStrings": {
"ConnectionName": "Data Source=database;Initial Catalog=catalogname;User ID=username;Password=password;"
},
But always the connection string with the connection name is null, and has:
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true