Question

I am storing a type in the EPiServer DDS that has a few properties such as string and guid. I now want to add a new property of type string to that type. How is it possible to get the DDS to recognise the new property added to the type and add it to the schema for the type in the DDS.

Was it helpful?

Solution

You need to remap the type to the store like this:

Let's say your class is called Car

var store = DynamicDataStoreFactory.Instance.GetStore(typeof(Car)); store.StoreDefinition.Remap(typeof(Car)); store.StoreDefinition.CommitChanges();

If you're then going to use the store instance directly after then do a refresh:

store.Refresh();

You can find more info about the DDS here: http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-60/Dynamic-Data-Store/

Paul Smith Developer Evangelist EPiServer

OTHER TIPS

The next version of CMS / EPiServer Framework will ship with a PowerShell cmdlet to do this from a script.

For the CMS 6 version I suggest you add the code to the Global.asax or create an initialization module

(http://world.episerver.com/Blogs/Magnus-Strale/Dates/2010/2/Changes-in-the-initialization-system-from-EPiServer-CMS-6-RC1/)

You can first check if the type and store are aligned:

var store = DynamicDataStoreFactory.Instance.GetStore(typeof(Car)); if (!store.StoreDefinition.ValidateAgainstMappings(typeof(Car), false)) { store.StoreDefinition.Remap(typeof(Car)); store.StoreDefinition.CommitChanges(); }

This way you only remap when needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top