I have a system comprising 5 applications. Each app accesses a database via a DAL library. In the DAL i have an app.config with the following entry:
<connectionStrings>
<add name="DataAccessLayer.Properties.Settings.ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\something\something\MyDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Using the full path for the attachDbFilename works fine. But I'm not happy:
I have copied the app.config file into each app that uses the database. Best way of doing this - copying the DAL app.config as a Link in the other projects?
I dont want a full path, when it comes to deployment that aint going to work. Relative paths in the app.config do not appear to work. Ideally I would like to be able to pull the DAL from source control onto any computer and not have to worry about changing the connection string each time. This: http://blogs.msdn.com/b/smartclientdata/archive/2005/08/26/456886.aspx talks about |DataDirectory| for deployment purposes but this doesn't work for me in debug (unless I'm using it wrong, see 3)
This might be better as a separate question but it is related to 2. - Is there a "good" way of arranging multiple projects for debug? I have created a Bin dir and in each project settings I copy the dll/exe to this bin dir. I also have a copy of the database in here (I tried no path in the app.config but that didn't work either, nor did |DataDirectory|). Also incredibly annoying is that relative paths do not work in Debug\Working Directory setting either, so it looks like that is one place that would have to change each time code is checked out to a new machine?
Apologies for the war and peace and thanks in advance for any ideas.