Issue with DDS setup

Vote:
 

Hello,

I am working on a POC with Dynamic data saving and retrieving and have followed the below article.

https://roland.kierkels.net/2014/10/storing-data-using-episerver-7-5-dynamic-data-store . Howe

I get Object variable not set error while saving a new record on the line .

var store = DynamicDataStoreFactory.Instance.CreateStore(typeof (Comment));

Not sure if I am missing anything in the config file or an initialization module.This is what I have in the config: Can someone point me what am I missing.

Note: I am doing this in a class library so that I can reference it later in web project if we decide on going with DDS.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="episerver.dataStore" type="EPiServer.Data.Configuration.EPiServerDataStoreSection, EPiServer.Data" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EPiServer.Framework" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.13.1.0" newVersion="11.13.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EPiServer.Licensing" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.13.1.0" newVersion="11.13.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EPiServer.Data" publicKeyToken="8fe83dea738b45b7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.13.1.0" newVersion="11.13.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<episerver.dataStore>
<dataStore defaultProvider="EPiServerSQLServerDataStoreProvider">
<clear />
<providers>
<add name="EPiServerSQLServerDataStoreProvider" description="SQL Server implementation of Data Store" type="EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider, EPiServer.Data" connectionStringName="EPiServerDB" />
</providers>
<cache defaultProvider="nullCacheProvider">
<providers>
<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" />
</providers>
</cache>
</dataStore>
</episerver.dataStore>
<connectionStrings>
<clear />
<add name="EPiServerDB" connectionString="Server=localhost;Database=dbname; User ID=sa;Password=;Connection Timeout=60;Integrated Security=false;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>

</configuration>

#207810
Oct 03, 2019 20:51
Vote:
 

What version of Episerver CMS are you using?

Try adding this attribute to your Comment class:

[EPiServerDataStore(AutomaticallyCreateStore = true, AutomaticallyRemapStore = true)]
public class Comment : IDynamicData
{
      // Required to implement IDynamicData
      public Identity Id { get; set; }
 
      // Save datetime comment was created
      public DateTime DateTime { get; set; }
 
      // Save pageID of page on which comment was created.
      public int PageID { get; set; }
 
      // Save name of person who commented
      public string Name { get; set; }
 
      // Holds the actual comment
      public string Text { get; set; } 
}

Then

var store = DynamicDataStoreFactory.InstanceGetOrCreateStore(typeof(Comment));

var comment = new Comment();
// Initialize comment, make sure the Id property are set.

store.Save(comment);

#207812
Oct 04, 2019 7:42
Vote:
 

Hi Dileep,

As you are using a different class library project so make sure your DB context is initialized properly before you perform any operation.

You can refer an article here-

https://world.episerver.com/blogs/Valdis-Iljuconoks/Dates/2011/10/If-all-you-need-is-just-Dynamic-Data-Store/

Thanks

Ravindra S. Rathore

#207844
Oct 07, 2019 8:29
Vote:
 

Thanks for the information. However with same code used inside the application was working fine so I have left it for now. I believe it could be because of DB initializarion but couldnt find out what was wrong.

#208314
Oct 21, 2019 20:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.