My solution has a lib class project with a database (my DAL) and a web project that will act as a WCF service level.
I add a link to the DAL project from the web project, and when I compile, my database is copied to the Bin folder of the web project.
The Web.config file requires a connection string. If I use:
attachdbfilename=|DataDirectory|\Test.mdf
he searches for the database in the App_Data folder.
I can easily place a copy of the database in the App_Data folder, however at this stage of development I make frequent changes to the scheme (via a copy in DAL) and I would like the project to load the version copied to the bin folder of the WCF layers.
I know that I can change the default DataDirecty as follows:
AppDomain.CurrentDomain.SetData("DataDirectory", path);
A) Without using a hard-coded absolute path, is there a better way to force the connection string to use the bin folder?
B) If I change the default DataDirectory parameter, how can I programmatically get an absolute link to the bin folder?
<Rant> Should Visual Studio 2010 be smart enough to implement project types, and instead of pulling the database from the referenced assembly into the bin folder, the App_Data folder was used instead? </Rant>
source share