I'm trying to set relative path of database file into my web.config
. I have two projects: DAL (class library), WebApi application. My database store in App_Date
folder in DAL. I want to set the connection string to web.config
of WebApi project.
<add key="connectionString" value="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|Data Directory|\DAL\App_Data\Taskstorage.mdf;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"/>
And this is another example:
<add key="connectionString" value="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=~\..\DAL\App_Data\Taskstorage.mdf;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"/>
None of them is working. Could you tell me how to fix this problem?