How do I create a Solution Wide Connection String
Does anyone know if it is possible to create a single connection str开发者_StackOverflow社区ing that will be accessible to all the projects in a solution (we have about 6).
I can create a text file with this information, but we need design time support as well, and it is not practical to have a connection string in every App.Config and Web.config file in the solution.
We basically want a Single connection string that is easy to change should the location of the db change, that will also be used by the IDE for design time support
Not sure, can't you just put a new config file to the solution items and include and load it in all projects?
Edit: I am specifically talking about a general (XML) config file, not an "App.config". Is has exactly the same format, it just goes by a different name. Add this file to your solution items and access it using OpenMappedExeConfiguration. You can find an additional example here.
put the connection string in the config of your "main" project. Create a Data Access project with a connectionstring property. Set this property when you initialise your project and use the Data Access project for all database related actions in all 6 projects
精彩评论