In this tutorial, you will learn the recommended way to rename existing properties that have been defined on either a page-type or a block-type within Episerver. Having good naming conventions is an important aspect of good design. Content editors should be able to understand the purpose of each property defined in every page and block. If a content editor does not know what a property does then you have a bad design.

Bad naming can result from different factors. The most common one is miscommunication when the project was built. Another common reason why you may want to rename a property is that the intention of the property changes over time. What once used to be a text string now needs to be a rich-text area. Renaming a new property is very easy. Renaming an old property or changing its underlining data type is more difficult. What happens when content has been stored within the database already? Refactoring a property might cause Episerver to encounter issues when it is trying to read existing data. This is where Migration Steps can help. MigrationSteps can be really handy for tasks like content import/export, refactorings and updates, and syncing new development changes between different environments.

One tip when refactoring properties, instead of trying to change the type or name of an existing property, it is much safer to create a new property, map the data from old to new. For a short period, you can hide the old property from the CMS using the [Ignore] attribute. Eventually, you can then delete the old property. This workflow is less risky, however, how do you map the data from one property into another one?

A MigrationStep can be used to help migrate data from an old field into a new one. The MigrationStep can be found within the EPiServer.DataAbstraction.Migration namespace. Creating a migration step is very easy:

To create a custom migration step, inherit from 'MigrationStep'. Override the AddChanges() method. In this method, you can add the code to map the data from old to new. This can be done using the ContentType() method to type the data. You can then use the UsedToBeNamed() method to tell Episerver how to map the property.

To learn more you can read the official documentation here