This question is locked. New answers and comments are not allowed.
If you have a project that contains your domain model and the associated context, it will have its own App.Config that looks something like this:
For Telerik ORM version 2010.2.714 (Jul 14, 2010), when you include that project from a WPF application and create your context with a: MyContext context = new MyContext(); it will give an error containing this:
'format of the initialization string does not conform to the specification starting at index 0'
As suggested by Telerik in the other thread, you can copy the connectionstrings section of App.Config to the local WPF application app.confg, but I don't like this, as it puts configuration settings in two places, which makes for configuration management headaches.
You can edit the dynamically created MyContext.cs file and set connectionStringName (from 'My_DBC') to the actual connection string as follows:
Clearly, this is undesirable. Instead, I would expect code in OpenAccessContext that would check the running assembly and deduce that the model is in another, and get the connection string from there. To do that, the connection string would need to be stored as an assembly resource, instead of in app.config. I really like that approach, since it is clean and supports easy DLL xcopy distribution. I know it goes counter to Microsoft's approach a bit. It is too bad that there is not a System.Configuration.ConfigurationManager.ConnectionStrings does not support this for assemblies as well as app.config files.
My solution for now is to set the connection string in my database initialization function, which is called on application startup. I have a static variable where I store the connection string, making the value in App.Config unused, except for design-time. Then, I modified MyContext.cs so that the constructors that take a connection string set connectionStringName = connection, so that the many later parameter-less calls to new MyContext() will use it. I still don't like editing the auto-generated file, but see no alternative for now other than copying the section in app.config to every client (ASP.NET, WPF, WCF) I have (there are several that use the same model library).
I suggest that Telerik make some changes to the auto-generated MyContext code to reflect the above, or something similar. Maybe an explicit call that lets you modify connectionStringName? Better yet, add a static string called connectionString, which if non-null is used instead of connectionStringName.
This is the same issue as discussed at the end of the Azure connection string problem thread.
<?xml version="1.0"?><configuration> <connectionStrings> <add name="My_DBC" connectionString="data source=(local)\SQL2008;initial catalog=My_DB;integrated security=True" providerName="System.Data.SqlClient"/> </connectionStrings><startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>For Telerik ORM version 2010.2.714 (Jul 14, 2010), when you include that project from a WPF application and create your context with a: MyContext context = new MyContext(); it will give an error containing this:
'format of the initialization string does not conform to the specification starting at index 0'
As suggested by Telerik in the other thread, you can copy the connectionstrings section of App.Config to the local WPF application app.confg, but I don't like this, as it puts configuration settings in two places, which makes for configuration management headaches.
You can edit the dynamically created MyContext.cs file and set connectionStringName (from 'My_DBC') to the actual connection string as follows:
public partial class MyContext : OpenAccessContext{ private static string connectionStringName = @"data source=(local)\SQL2008;initial catalog=My_DB;integrated security=True";}Clearly, this is undesirable. Instead, I would expect code in OpenAccessContext that would check the running assembly and deduce that the model is in another, and get the connection string from there. To do that, the connection string would need to be stored as an assembly resource, instead of in app.config. I really like that approach, since it is clean and supports easy DLL xcopy distribution. I know it goes counter to Microsoft's approach a bit. It is too bad that there is not a System.Configuration.ConfigurationManager.ConnectionStrings does not support this for assemblies as well as app.config files.
My solution for now is to set the connection string in my database initialization function, which is called on application startup. I have a static variable where I store the connection string, making the value in App.Config unused, except for design-time. Then, I modified MyContext.cs so that the constructors that take a connection string set connectionStringName = connection, so that the many later parameter-less calls to new MyContext() will use it. I still don't like editing the auto-generated file, but see no alternative for now other than copying the section in app.config to every client (ASP.NET, WPF, WCF) I have (there are several that use the same model library).
I suggest that Telerik make some changes to the auto-generated MyContext code to reflect the above, or something similar. Maybe an explicit call that lets you modify connectionStringName? Better yet, add a static string called connectionString, which if non-null is used instead of connectionStringName.
This is the same issue as discussed at the end of the Azure connection string problem thread.