App.Config ConnectionString - External Library

7 posts, 0 answers
  1. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jun 2012

    Posted 30 Nov 2012 Link to this post

    I have a coded step where I am calling my Entity data access layer.  Problem is that they enity framework complains about not being able to find the name connection.

    Exception Thrown in my DAL:
    The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

    Issue:
    I created the App.Config file in my test project and included the connectionstring.  Issue is that the test project gets build as a library and not an application, therefore the app.config file never gets used.
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/override-app.config.aspx

    Question:
    How do I get my Entity DAL to access the named connection that it needs access to when the app.config file does not exist.



  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 03 Dec 2012 Link to this post

    Hi Andrew,

    Unfortunately it is not possible to get your data access layer to access the named connection if the app.config file does not exist.

    Without actually seeing your code and being able to reproduce the error, I can only make blind guesses why you are not able to get the connection string stored in your app.config file. Please provide a copy of your project and the complete failure information, so that we ca analyze it and try to determine what is causing the problem.

    If you deem that information too sensitive for this forum, you can reopen your support ticket(636092) and attach it there. Thanks for providing the information we need to best assist you.

    All the best,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jun 2012

    Posted 04 Dec 2012 Link to this post

    Please see attached file. There is a readme.txt in there with instructions. I've tried to simulate our project as close as possbile.

    Ignore 4A in the instructions.

    Thanks,
    Andrew
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 05 Dec 2012 Link to this post

    Hi Andrew,

    Thank you for providing the project. In order to overcome the problem you are experiencing please take the following steps:

        1. Create a Test Settings(.testsettings) file in your solution and enable deployment.
        2. Add the TestStudioProject.dll.config file as deployment item.
        3. Open the App.config file(the one located in the TestStudioProject) and enter the correct connection string. It should be something like this:
    <add name="TempDataBaseEntities" connectionString="data source=AUSTIN1\PLAMEN;initial catalog=TempDataBase;integrated security=True;multipleactiveresultsets=True;" providerName="System.Data.EntityClient" />

        4. Use the code provided in this article to get the Connection String from the App.config in a coded step.
        5. Use the code provided in this article to access your database entries.   

    See this video demonstrating how this works. I'm also sending you back your project with the required changes. Please take a look at it and let me know if you need further assistance on this.                      

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jun 2012

    Posted 06 Dec 2012 Link to this post

    I am not concerned with accessing the App.Config value within a coded step and not interested in the connecting to SQL Server.

    I want to be able to use the Entity library that is in my solution that connects to SQL Server, but the entity library needs access to the named connection that is stored in the calling app.config.

    How do I call the entity library within my project within a coded step in test studio?

    Thanks,
    Andrew
  6. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jun 2012

    Posted 06 Dec 2012 Link to this post

    The enitty object has an overloaded constructor which accepts a connection string.  We will just use this to connect to the entity frame work.  Problem solved, thanks for the help.

    But, if there is a way to use the app.config directly without having to strip it out in a coded step that would be ideal, but no biggy.

    Thanks,
    Andrew
  7. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 10 Dec 2012 Link to this post

    Hello Andrew,

    I am glad to hear you got it working! Thanks for the update. Unfortunately currently there is no way to access the config file without using a coded step.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top