I have a project A and a project B. Project A has a dependency on project B. B contains a database file (.mdf) that I'd like to attach in A.
To do that I simply use
<add name="myDB"
connectionString="Data Source=(LocalDB)\mssqllocaldb;
AttachDbFilename=|DataDirectory|\myDB.mdf;
Database=some_alias_for_myDB;
Integrated Security=True" />
Then, I build project A and start it and it successfully uses myDB. However, I want every time I start project A, to start with a fresh copy of myDB. If myDB.mdf was a part of project A, I would simply put a property Copy to Output Directory : Copy Always on myDB.mdf. In the case where myDB.mdf is transitively received, the value of the property Copy to Output Directory makes no difference to project A.
P.S. I also tried pre-build events to clean my project before building it - doesn't work because starting project A, when unmodified, does not trigger a build, therefore no cleaning is done.
In the end I decided to add a link to the common file. So in my project A I have a relative link
../B/myDB.mdf. It is not the best solution, imo, since the project references now something outside of its domain folder, however it seems better than custom copy scripts.