Managing Connection Strings (using current OpenAccess Releases)

Thread is closed for posting
5 posts, 0 answers
  1. James Legan
    James Legan avatar
    54 posts
    Member since:
    Sep 2008

    Posted 22 Feb 2012 Link to this post

    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?

  2. Zoran
    Zoran avatar
    534 posts

    Posted 27 Feb 2012 Link to this post

    Hello James, 

    I understand your point in this case. There is an article that is currently addressing the connection strings management in OpenAccess, but there is definitely room for improving it, so the customers can fully understand how connection strings are used with OpenAccess and the reasons behind any of the points there.

    1. The connection string serialized in the .rlinq file is not actually used by the UpdateDatabase From Model Wizard. It is saved a setting, for the selected connection string in the Add New Item Wizard. What is actually used during design time, is only the connection string in the App.config, since working with the product in runtime regime, uses the application configuration file in order to resolve the connection string. In the scope of the designer, this is a app.config file of the project which contains the .rlinq file.
    2. In the scope of an executable application, or a web site, the configuration file used, is not the one of the project containing the .rlinq file, but the configuration file of the project being executed. In the web site case, that is of course, the web.config.
    3. There is no way for the designer to use the connection string from the web.config, which is in fact you actual connection string since it has no reference to the web site, but it is the other way around.
    So if you would like to use the designer, you should always have two connection string synchronized, the web.config and the app.config connection string from the project that contains the .rlinq file.

    All the best,
    the Telerik team
    Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
  3. KaliCharan
    KaliCharan avatar
    5 posts
    Member since:
    Jan 2013

    Posted 04 Jan 2013 Link to this post


    I have created a silverlight application and it is working fine.Now i need to create reports and i am using telerik reports.My question is i want to access the connection string that is mentioned in wcf service web.config file.How can i access this in report class library? Its very urgent. I will be very thankful if you answer this as soon as poosible as client want to release the product and they are waiting for this to be fixed.

  4. Steve
    Steve avatar
    10940 posts

    Posted 08 Jan 2013 Link to this post

    Hello Charan,

    This forum thread is for the OpenAccess product and not for Telerik Reporting. We kindly ask you to open threads in the correct product category in order to receive an answer from the respective team.

    As for your inquiry, point #2 from the previous reply covers your question as well - In the scope of an executable application, or a web site, the configuration file used is the configuration file of the project being executed i.e. in case of Silverlight application, that would be the config file of the application hosting the Silverlight app.

    Kind regards,
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  5. KaliCharan
    KaliCharan avatar
    5 posts
    Member since:
    Jan 2013

    Posted 09 Jan 2013 Link to this post

    Hi Steve,

    Thankyou for your reply,but i resolved this issue.

Back to Top