I have been struggling with this issue for quite some time and have come up with some innovative solutions using static datasources (like a SQL table) and T4 templates to manage connection strings. While this process has become familiar to me but I have to believe that there is a "better" way that either exists and has completely escaped me OR something that is in the works that I cannot wait to get my hands on down the road.
The scenario is fairly simple:
Solution: IIS hosted WCF Service which consists of two projects.
- Project 1: Website which contains the .SVC and a web.config that contains the end points/bindings.
- Project 2: WCF service library that contains among other things an .rlinq file and all of my classes which use it.
Database: SQL Server 2008 R2 which contains two databases "Production", "Development".
Requirement: The ability to specify in a single location the connection string that should be used.
Reality: Given the current design (easily replicatable by creating a new VS2010 solution with a website, class lib and an OpenAccess Domain Model), there is a connection string stored in the .rlinq that OA uses when mapping to the database, retieving schema info, etc..., a connection string is added to the app.config of the class library when adding the .rlinq file (which is accessible and works when testing the library directly with the WcfTestClient.exe but fails when accessing the application through IIS) and the one that I need to manually copy and paste into the web.config of the Website (Project 1) of the solution so that the application will execute properly when hosted in IIS.
Now I have found a ton of examples from 2009 including Facebook posts from Telerik on how easy OA makes this but all of those are based on the initial design of OA where we were playing with ObjectScopeProviders directly which I am happy to say is largely in the past.
What I cannot find anywhere is documentation that addresses the vary real, every day scenario decribed above. Am I missing something or is this just the reality and a drawback to a product I love and use daily?