Renaming an Episerver page property using a migration step

Content types (like page types and block types) may be safely renamed, as long as you specify a GUID parameter in the ContentTypeAttribute of the class. The properties defined on a content type do not have the optional GUID parameter. If you simply rename a page property Episerver will just add another property to the same page.

To ensure that the existing property is renamed, and retain the value it had before it was renamed, you should use a migration step.

using EPiServer.DataAbstraction.Migration;

namespace Example
    public class RenamePropertyMigrationStep : MigrationStep
        public override void AddChanges()

        private void RenameProperty()

The code above will rename the property Text to MainBody for the page type called ArticlePage.

Remember that you must also change the name on the page type class. Changing this:

public virtual XhtmlString Text{ get; set; }

To this:

public virtual XhtmlString MainBody{ get; set; }

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *