This is a migrated thread and some comments may be shown as answers.

App.Config ConnectionString - External Library

6 Answers 213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Nov 2012, 04:30 PM
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.



6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 03 Dec 2012, 11:54 PM
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
0
Andrew
Top achievements
Rank 1
answered on 04 Dec 2012, 08:34 PM
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
0
Plamen
Telerik team
answered on 05 Dec 2012, 10:15 PM
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
0
Andrew
Top achievements
Rank 1
answered on 06 Dec 2012, 06:59 PM
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
0
Andrew
Top achievements
Rank 1
answered on 06 Dec 2012, 07:26 PM
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
0
Plamen
Telerik team
answered on 10 Dec 2012, 08:44 PM
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
Tags
General Discussions
Asked by
Andrew
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or