Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

CMS data migration



We are about to migrate the CMS content from an older website to a new. All page types differ but they have some common properties which we could map. However the new pages still needs alot of manual inrichment before they can be used. We use several sites and several languages. We also want to migrate assets.

What is the best practice for this? Any good ideas on how to approach this? Is it even worth doing or is it easier to just create everyting from scratch?

// Patrik @ Avensia

Apr 15, 2015 13:42


we have done quite a few migrations from EPiServer CMS 4, 5 and 6 to CMS 7 and the approach we have taken is to build a custom migration tool that uses the built in events ContentImporting and ContentImported. We use the normal import package and our tool helps us with the heavy lifting. I don't know if this helps you but the following commented code example will explain the main building blocks.

// The migration library will scan the assemblies of the bin folder
// looking for classes marked with the MigrationInitializer attribute
// and a public static void Initialize method which it will happily call.
public static class MigrationDefinitions {
  public static void Initialize() {
    // Register your mappings using the static Register method of the 
    // MapperRegistry class. This method accepts a variable parameter list
    // if IPageMapping instances

      // Hopefully you will not need to implement the IPageMapper interface
      // yourself, but use the PageMapper fluent API instead. The starting
      // point of the API is the Define method which accepts a name for the
      // mapping
      PageMapper.Define("Mapping name")

        // The Map method defines a mapping for a page type. The new strongly 
        // typed content type is specified as the type argument and the name 
        // of the old page type is given as the first argument. 
        .Map<NewsListPage>("[Old] NewsArchive",

          // The second argument to Map is an Action<SourcePage, TNew> callback
          // in which you specify how properties are mapped. The SourcePage
          // class contains the properties of the page being migrated and has
          // a couple of helpful methods you can use to get the values. 
          // This example uses the GetValueWithFallback method which falls 
          // back to the next property in the list when a previous value does
          // not exist or is null
          (s, d) => d.Heading = s.GetValueWithFallback<string>("Header", "PageName"))

        .Map<NewsPage>("[Old] NewsItem",
          (s, d) => {
            d.Heading = s.GetValue<string>("Header");
            // Sometimes you'll need to clean up content from the old pages
            // This is best done via extension methods. A few are defined in
            // the library which may or may not be of use to you
            d.Introduction = s.GetValue<string>("Ingress").CleanupForIntroduction();
            d.MainBody = s.GetValue<XhtmlString>("Bread").CleanupForMainBody();

        // You may leave the Action argument if no properties are mapped
        .Map<ContainerPage>("[Old] Folder")

        // The Default method defines the mapping for all pages where a mapping
        // cannot be found.
          (s, d) => {
            d.Heading = s.GetValueWithFallback<string>("MainHeader", "Header", "PageName");
            d.Introduction = s.GetValue<XhtmlString>("Ingress").CleanupForIntroduction();
            d.MainBody = s.GetValue<XhtmlString>("MainBody").CleanupForMainBody();


Apr 15, 2015 15:11

Ah, a customized mapper. That's nice. I might use this if the standard convert function is not enough. Thanks :)

Apr 16, 2015 9:18
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.