November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Yeah, using ConfigurationManager.ConnectionStrings
is indeed the easiest way to get connection strings.
But if you want an injected abstraction, you can have a look at the IDatabaseConnectionResolver
interface. And if you run a Commerce solution, the IConnectionStringHandler
interface is even simpler to use.
Late to the party, but just to add - don't rely on fact that connection will always be named "EPiServerDB". it can be anything.
To get the name of the connection string used in solution - you can use "EPiServerDataStoreSection.Instance.DataSettings.ConnectionStringName" property value.
I'm following a tutorial related to storing custom data in Episerver, and one of the libraries referenced is IDatabaseHandler, which is obsolete. The documentation states to use IDatabaseHandler, but the property I'm looking to access from IDatabaseHandler is the ConnectionsStrings, which is not valid on that interface. Can someone provide me the best route to obtain the ConnectionStrings.ConnectionString lookup interface for the latest library, so I can access the database for creating a custom table?
Thank you,