0

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.

Reinier Torenbeek
  • 16,669
  • 7
  • 46
  • 69
Jet Basrawi
  • 3,185
  • 2
  • 15
  • 14

2 Answers2

3

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

  • Hi Paul, thanks for that answer, that has solved the biggest part of the problem for me now the issue is simply where would one actually make these calls? By this i mean that this is something that would only happen occasionally and so I am thinking that it is something that should be run once at design time like a script to do the remapping and not a general part of the codebase using the DDS. how have you used this in the past? – Jet Basrawi Dec 02 '10 at 14:14
2

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.