I have a n-tiered wpf application using EF in Data Access Layer. The simplified structure looks like this
- DataProject.csproj
* data.config
* Repository.cs
- Presentation.csproj
* presentation.config
* PresentationCode.cs
As may be seen DataProject.dll is referenced by Presentation.csproj
I use ConfigurationManager in my Repository.cs to get the ConnectionStringSettingsCollection, but ConfigurationManager by default accesses the presentation.config by default, even though the code is called from Repository.cs in DataProject. And this is how is should be.
My question is how should I then access the connection strings correctly as there are several options open.
Copy the connection strings section from data.config to presentation.config. But what if the connection changes ? I have to keep changing them in presentation.config file.
Should I point a link to data.config file from presentation.config file.
<configuration>
`<connectionStrings configSource="connections.config"/>`
</configuration>
- Or should I use
ConfigurationManager.OpenExeConfiguration()to access the data.config.
Currently, I find option 2 as the best option as it takes less refactoring and maintenance later. But I would be glad to know the appropriate approach.
Edit:
Is there a way that EF points directly to my presentation.config file to access the connection strings ?