This question is locked. New answers and comments are not allowed.
Noam Berda
Top achievements
Rank 1
Noam Berda
asked on 13 Oct 2011, 07:58 AM
Hi,
This is a basic question but i couldn't find the answer on the forum or the help site.
I have a ORM model that i am developing on SQL Server 2008 R2 and the connection string is in the Web.Config. No problem with that.
Then i have a Web.Deploy.Config that i am using when i am deploying my site to Azure. the deploy config alter the web.config and change the connection string for the azure. no problem with that as well.
the problem is that i need to set somewhere (BackendConfiguration Backend=Azure) i assume that it need to be in the Web.Config and then i could change it via the deploy configuration. Were and how do i set the backend type on the web.config? Noam
This is a basic question but i couldn't find the answer on the forum or the help site.
I have a ORM model that i am developing on SQL Server 2008 R2 and the connection string is in the Web.Config. No problem with that.
Then i have a Web.Deploy.Config that i am using when i am deploying my site to Azure. the deploy config alter the web.config and change the connection string for the azure. no problem with that as well.
the problem is that i need to set somewhere (BackendConfiguration Backend=Azure) i assume that it need to be in the Web.Config and then i could change it via the deploy configuration. Were and how do i set the backend type on the web.config? Noam
7 Answers, 1 is accepted
0
Noam Berda
Top achievements
Rank 1
answered on 14 Oct 2011, 11:24 AM
Hi,
Can someone help me on that please. How do I set up backend configuration in web.config when I am using a connection string?
Noam
0
Hello Noam Berda,
At the moment you have to add the logic. The easiest way is to use the app settings part in your web.config Just add a:
to your web.config. Now you can use this setting in the static ctor of your generated context class. Please add a partial class and add code like this:
Kind regards,
Jan Blessenohl
the Telerik team
At the moment you have to add the logic. The easiest way is to use the app settings part in your web.config Just add a:
<
appSettings
>
<
add
key
=
"OpenAccessBackend"
value
=
"mssql"
/>
<!--add key="OpenAccessBackend" value ="azure"/-->
</
appSettings
>
to your web.config. Now you can use this setting in the static ctor of your generated context class. Please add a partial class and add code like this:
using
System.Configuration;
namespace
ConsoleApplication19
{
public
partial
class
EntitiesModel
{
static
EntitiesModel()
{
string
backendString =
"azure"
;
//fallback
try
{
string
value = ConfigurationManager.AppSettings [
"OpenAccessBackend"
];
if
(value !=
null
)
{
backendString = value;
}
}
catch
{
//todo: error reporting
}
backend.Backend = backendString;
}
}
}
Kind regards,
Jan Blessenohl
the Telerik team
Check out the latest stable build of Telerik OpenAccess ORM. Download it and benefit from our new Project Templates.
0
Noam Berda
Top achievements
Rank 1
answered on 17 Oct 2011, 09:36 AM
Ok thanks, I will give it a try. I was expecting something like that.
Noam
0
Gary
Top achievements
Rank 1
answered on 29 Jun 2012, 07:31 PM
Is this still the recommended approach? It seems like I have to modify the generated code to make the property backend protected instead of private to get this to work.
Thanks,
Gary
Thanks,
Gary
0
Hello Noam,
If you use Azure this is still the only way to do it, but you do not have to change the generated code.
Please add a partial class to your generated context and override the OnDatabaseOpen method. Before calling the base class method you can now modify the passed in backend configuration object and set the right backend.
Kind regards,
Jan Blessenohl
the Telerik team
If you use Azure this is still the only way to do it, but you do not have to change the generated code.
Please add a partial class to your generated context and override the OnDatabaseOpen method. Before calling the base class method you can now modify the passed in backend configuration object and set the right backend.
Kind regards,
Jan Blessenohl
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.
0
Gary
Top achievements
Rank 1
answered on 03 Jul 2012, 02:29 PM
Thanks Jan, that works.
Gary
For those interested, this is what I have now:
Gary
For those interested, this is what I have now:
protected string BackendString
{
get
{
string backendString = "azure";
try
{
string value = ConfigurationManager.AppSettings["OpenAccessBackend"];
if (value != null)
backendString = value;
}
catch { }
return backendString;
}
}
protected override void OnDatabaseOpen(BackendConfiguration backendConfiguration, Telerik.OpenAccess.Metadata.MetadataContainer metadataContainer)
{
base.OnDatabaseOpen(backendConfiguration, metadataContainer);
backendConfiguration.Backend = BackendString;
}
0
Hi Noam,
We have a new way to integrate settings from the app or web.config. You can now easily specify all backend configuration settings in the app.config file and use them by merging with the coded settings by calling
BackendConfiguration.MergeBackendConfigurationFromConfigFile
For more information, please have a look here.
Sorry that I did not remember our new features.
Regards,
Jan Blessenohl
the Telerik team
We have a new way to integrate settings from the app or web.config. You can now easily specify all backend configuration settings in the app.config file and use them by merging with the coded settings by calling
BackendConfiguration.MergeBackendConfigurationFromConfigFile
For more information, please have a look here.
Sorry that I did not remember our new features.
Regards,
Jan Blessenohl
the Telerik team
OpenAccess ORM Q2'12 Now Available! Get your hands on all the new stuff.