Try our conversational search powered by Generative AI!

How to configure EpiServer 7 CMS, Dynamic Data Store in Console application


I want to create EpiServer 7 CMS page programaticaly, I find link
"" but unable to crate by console application.
basically I want to perform CURD operation for product,page,account and category etc. from console application.

Nov 08, 2013 8:08

What error are you getting?


Nov 08, 2013 8:51

Hi Frederik,

Please find a the details of the code at a snapshot below and please help me figuring out the issue

In my app config I entered

    <dataStore defaultProvider="EPiServerSQLServerDataStoreProvider">
        <add name="EPiServerSQLServerDataStoreProvider" description="SQL Server implementation of Data Store" type="EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider, EPiServer.Data" connectionStringName="EPiServerDB"/>
      <cache defaultProvider="nullCacheProvider">
          <add name="httpCacheProvider" description="Http Cache implementation for DataStore" type="EPiServer.Data.Cache.HttpRuntimeCacheProvider,EPiServer.Data.Cache" />
          <add name="nullCacheProvider" description="Null Cache implementation for DataStore" type="EPiServer.Data.Cache.NullCacheProvider,EPiServer.Data" />

And the initialization code is:

    var container = new StructureMap.Container();
    var factory = new SqlDatabaseFactory();
    container.Configure(ce => ce.For<IDatabaseHandler>().Use(factory.CreateDefaultHandler));
    ServiceLocator.SetLocator(new StructureMapServiceLocator(container));
    DataInitialization.InitializeFromCode(container, factory, null);
    var store = typeof(SampleModel).GetStore();

The exception I am getting is:

exception Message:
Activation error occurred while trying to get instance of type IDatabaseHandler, key ""

InnerException :

{"StructureMap Exception Code:  207\nInternal exception while creating Instance 'c83caeb3-0d4f-4775-853b-8b7ae906265a' of PluginType EPiServer.Data.IDatabaseHandler, EPiServer.Data, Version=7.0.859.24, Culture=neutral, PublicKeyToken=8fe83dea738b45b7.  Check the inner exception for more details."}


   at StructureMap.Pipeline.LambdaInstance`1.InstanceBuild(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.ObjectBuilder.ConstructNew(Type pluginType, Instance instance, BuildSession session)
   at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session)
   at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
   at StructureMap.BuildSession.<>c__DisplayClass3.<.ctor>b__1()
   at StructureMap.BuildSession.CreateInstance(Type pluginType)
   at StructureMap.Container.GetInstance(Type pluginType)
   at EPiServer.ServiceLocation.StructureMapServiceLocator.DoGetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
   at EPiServer.Data.Providers.SqlDatabaseFactory.get_CurrentHandler()
   at EPiServer.Data.DataInitialization.InitializeFromCode(IContainer container, IDatabaseFactory dbHandlerFactory, CacheProvider cacheProvider)


Nov 08, 2013 10:07

Had the same problem,

fixed it by using:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />

Jan 23, 2014 8:43

Chirag, sorry for delayed answer. We just came across the same issue. Check exception's inner exception. If structuremap is complaining about "Entry point is not found", double check your app.config file. You may missing redirect to proper structuremap assembly used in the project (as Gatis mentioned above):

<assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
<bindingRedirect oldVersion="" newVersion="" />


Jan 23, 2014 8:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.