Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override connection string (from settings.txt) in Orchard CMS

I deployed a web site in AppHarbor which uses a MS SQL database. AppHarbor provides me with a connection string which I entered in settings.txt and it seems to work fine BUT AppHarbor suggests to use the SQLSERVER_CONNECTION_STRING variable instead.

That is because the connection string may change without notice so the only safe way is to use the variable mentioned.

Accessing the configuration variables below should be done programatically, as the values may be updated by the add-on provider without notice.

Is there a way to override the DataConnectionString setting from settings.txt and set the application to use the SQLSERVER_CONNECTION_STRING variable instead? I assume AppHarbor somehow sets those variables as appSettings.

P.S. This is my first application with Orchard, I am not proficient with this CMS.

like image 208
lalibi Avatar asked Feb 11 '12 21:02

lalibi


1 Answers

The connection string is set in the ShellSettingsManager class. I'm not sure you can easily replace this dependency from a module, but you could certainly just change the line of code that sets the connections string...

shellSettings.DataConnectionString = value;  //use your config value instead

ShellSettingsManager is an implementation of IShellSettingsManager so you have some flexibility there if you want to just implement your own too.

like image 101
Brandon Joyce Avatar answered Dec 31 '22 08:12

Brandon Joyce