EPiServer 7 Preview – migration

I’ve previously written about the migration support in PTB 2 migrations. In Falcon EPiServer have added their own migration support. Let’s start with a simple page type

[ContentType(GUID = "41E02EB2-EF5E-4193-93FD-2D079B1E8AC7",
    DisplayName = "My page",
    GroupName = "AlloyTech",
    Description = "Bla bla")]
public class MyPage : AlloyPage
        Name = "The property",
        Description = "Bla bla bla"
        GroupName = AlloyTabNames.SEO,
        Order = 1)]
    public virtual String TheProperty { get; set; }

And then we’ll give it a value

Changing the property name

If we were to change the property name EPiServer have no real way of knowing what the property name was before and what the new name is. In the case of changing a page (or content as I guess they would be called from now on) type where we have given a Guid it can use that to identify the type and perform a simple rename. Properties aren’t identified by guids so let’s see what happenes when we change the property name

    Name = "The property with new name",
    Description = "Bla bla bla",
    GroupName = AlloyTabNames.SEO,
    Order = 1)]
public virtual String ThePropertyWithNewName { get; set; }

Our page now looks like this

As we can see the following has happened:

  • We have two properties, one with the old name and one with the new
  • Since the property with the old name has values entered it is not removed. Since EPi doesn’t know what tab the property is connected to it’s shown under the content tab
  • The page type in admin mode shows that the property with the old name is missing from code

This is a great “safe by default” way of handling this since we don’t ever loose any data. In this case we would like to “move” the data from the old property to the new and this is where migrations come into play.


EPiServers implementation of this is fairly similar to the one found in PTB. In our case of telling EpiServer that the property ThePropertyWithNewName was previously called TheProperty the migration could look like this

public class MyMig : MigrationStep
    public override void AddChanges()

With this hint in place EPiServer now knows that the property was renamed and the value can be “migrated”.