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

[Solved] Connection String Question

3 Answers 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dan
Top achievements
Rank 1
Dan asked on 11 Nov 2009, 08:15 PM
It seems that an Open Accesss ORM in a dll cannot compile without a valid database connection string in it's config file.  When you reference this assembly from an executable that uses the ORM, the connection segments are copied over.  In my case, I opted to use the new method of standard ADO.Net connection strings for the ORM.  I see that there are 2 copies of this string, one in the standard Connection Strings section of the config and one under OpenAccess settings. It appears from some testing that only the connection string in the standard configuration/connectionStrings sections is used.  Is this correct?  It also appears that the backendconfiguration and mappings sections aren't needed in the exe's app.config.  My goal is to try to keep the exe's app.config as simple as possible.
 
Thanks for your assistance.

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 12 Nov 2009, 08:36 AM
Hello Lars Solberg,

The connection string is copied to the OpenAccess connection node just as a precaution and is used only in case of a missing connection string with the required name in the global connection strings section. Otherwise the connection string in the standard <connectionStrings> node is used. Having that in mind, all you should have in the configuration file of the executable project is a connection string with the same name as the OpenAccess connection. It will override the connection string specified in the OpenAccess settings.
We hope this approach will make the deployment of applications that use our product easier.

Kind regards,
Alexander
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michael
Top achievements
Rank 1
answered on 29 Jan 2011, 06:31 AM
OK.

did some reading...and its stated quite plainly that all projects that call it need the connection string....doh... leaving the rest as testament to my stupidity


I'm getting a connection string error in my app and wondering if you can clarify the above explanation the error is:
yet my app file (though the one containing the ORM) contains
<add name="AKCompoundEntityDiagrams" connectionString="data source=C:\Users\Owner\Documents\Visual Studio 2010\Projects\RadArtzCompound\RadArtzCompound.Data\Data\AKCompound.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />

do i need this string in the test project?

and yes i know i shouldnt be running unit tests against the database... but I was getting the same error in the app & so thought to try it in a test and simplify things??

help appreciated
0
Serge
Telerik team
answered on 02 Feb 2011, 08:36 AM
Hi Michael,

 If you want to test with the same connection string in your test project this should be enough. However I would strongly encourage you to create a separate test database that you use for this purpose. And add that connection string to your testing project. The connection string is needed in the project that is executed, so if you want to use OpenAccess in the test project you will need it there, or you can just create the object context with a connection string.

Tests against the database are not bad, however they should definitely not run against the production database. 

I hope this proves to be helpful, however if you face further trouble be sure to let us know.

Kind regards,
Serge
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Michael
Top achievements
Rank 1
Serge
Telerik team
Share this question
or