November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Not sure what you meant but episerver cms connection string name is always EPiServerDB
The connections.config file has the following strings:
<connectionStrings>
<add name="EPiServerDB" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|EPiServer.Cms.mdf;Initial Catalog=EPiServer.Cms;Connection Timeout=60;Integrated Security=True;MultipleActiveResultSets=True" />
</connectionStrings>
referenced in this part of the web.config:
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="EPiServerDB" applicationName="/" />
</providers>
The name of this string is EPiServerDB. But what when this is changed? Then my querry for the database name, using the connection string will result in an error.
So how can I get the correct name of the database episerver uses, without specifing any name, that could potentialy be changed by a user somewhere down the line?
the connectionstring name is a const and will not be changed, because it will break all other parts in the system.
I am making a nuget package, that will save some things into episerver database.
I dont know what is the name of the dabase, and I dont know what is the name of the connection string.
I need to use the episerver database and cannot create a seperate database.
I would prefer to use Entity Framework.
It all boils down to " How to extract the name of the main episerver database without explicit names and magic strings."
var epiDataOptions = context.Locate.Advanced.GetInstance<DataAccessOptions>();
var connectionName = epiDataOptions.DefaultConnectionStringName; // will return `EPiServer` or any other configured connection string name
name of the connection string can be changed by adding following line in web.config file (or any other where you have <episerver.dataStore> section):
<episerver.dataStore>
<dataSettings connectionStringName="ThisIsMyConnectionName" />
</episerver.dataStore>
but default one is "EPiServerDB"
`context.Locate.Advanced` is just a shortcut used in init modules to get to Service Locator
Hi!
I need to get the main episerver database name to use with entity framework.
I know I could get it from
System.Configuration.ConfigurationManager.ConnectionStrings
but I will not have the name of the string so this is useless.It could be retrieved from
EPiServer.Data.Providers.IDatabaseFactory
, but that interface is obsolete :(Is there a built in method that will return the main episerver database name?