We're trying to have Umbraco use a connection string we pass it from the code. Reason being, we get the connection string from outside of the web.config and we can't change this constraint.
Is it possible to do this? We are not allowed to modify the web.config from the source code as well so editing it from the code to add the UmbracoDbDSN parameter is not an option...
We've tried and used this successfuly but we are unfortunately not allowed to modified the web.config file anymore...so this solution couldn't work for us.
Spent some time testing this solution as well but whichever way I try to access the configuration it is read only (ApplicationContext.DatabaseContext.Database.Connection.ConnectionString is readonly)
What I was hoping for was a way to hook up in the Umbraco database layer initialization and being able to "inject" a different connection string. But looking at the Umbraco source code, it doesn't seem to be feasable...any suggestion would be appreciated.
Use a different connection string
Hi
We're trying to have Umbraco use a connection string we pass it from the code. Reason being, we get the connection string from outside of the web.config and we can't change this constraint.
Is it possible to do this? We are not allowed to modify the web.config from the source code as well so editing it from the code to add the UmbracoDbDSN parameter is not an option...
Thanks
Hi Donatello,
Welcome to our community,
Try to look at this code :
Thanks, Alex
Hi Alex
thanks a lot for your help.
We've tried and used this successfuly but we are unfortunately not allowed to modified the web.config file anymore...so this solution couldn't work for us.
Looks like here is solution of your problem - https://our.umbraco.org/forum/developers/api-questions/56150-Connection-string-in-code
Spent some time testing this solution as well but whichever way I try to access the configuration it is read only (ApplicationContext.DatabaseContext.Database.Connection.ConnectionString is readonly)
What I was hoping for was a way to hook up in the Umbraco database layer initialization and being able to "inject" a different connection string. But looking at the Umbraco source code, it doesn't seem to be feasable...any suggestion would be appreciated.
Hi Donatello,
just want check with you, did you find any way to resolve your issue. I'm also facing the same issue.
Thanks, Nagendra
is working on a reply...