I have 2 projects in the solution - one class library with entities for database (using EF), one for Winforms.
Connection string is in app.config
of the Winforms application, and it works correctly:
<add name="LibraryContext"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\MyLibrary.mdf;Integrated Security=True; "
providerName="System.Data.SqlClient"/>
But when I try to provide migrations, I get an error:
A file activation error occurred. The physical file name '\MyLibrary.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
When I provide full path in connection string, everything works fine. I assume the problem is in DataDirectory
. The project with entities for database doesn't see it or maybe see it as own DataDirectory
and not the one for startup project (Winforms).
Please, help me to provide correct relative path for database.