How to migrate Sitecore users custom properties- PART 1

Recently, I was working on a Sitecore 8 to 9 migration where I’d to migrate all the user custom properties to Sitecore 9 CoreDB. Initially, I was assuming that I can move all the users and users’ custom properties using Serialization of all users from Sitecore admin login. But unfortunately, none of the custom properties were copied over after the deserialization onto Sitecore 9.

So I programmatically copied all the custom properties to a CSV file and the updated Sitecore 9 core db.

I explain my approach here in two separate section. First, let’s see how to copy all the custom properties to a CSV file.

Part 1 – Export custom user properties to CSV

Crete an aspx page in your Sitecore source (in my case sitecore 8.0.5) root folder. If you are doing it for a production environment then create this file under /Sitecore/Admin folder. I named this file as ExportUserCustomeProperties.aspx Then paste below given code into it and change profile custom properties based on your requirement

<%@ Import Namespace=”System” %>
<%@ Import Namespace=”System.Linq” %>
<%@ Import Namespace=”System.Text” %>
<%@ Import Namespace=”System.Collections.Generic” %>
<%@ Import Namespace=”Toshiba.Core.Agents” %>

<%@ Page Language=”C#” Debug=”true” %>

string log = string.Empty;
public void Page_Load(object sender, EventArgs e) {

public void ExportUserProfileToCSV() {
var users = Sitecore.Security.Accounts.UserManager.GetUsers();
if (users != null) {
StringBuilder sb = new StringBuilder(“”);
foreach(Sitecore.Security.Accounts.User user in users) {
if (user != null) {
var user1 = Sitecore.Security.Accounts.User.FromName(user.Name, true);

var profile = user1.Profile;

string lines = string.Format(“\”{0}\”,\”{1}\”,\”{2}\”,\”{3}\”,\”{4}\”,\”{5}\”,\”{6}\”,\”{7}\”,\”{8}\”,\”{9}\”,\”{10}\”,\”{11}\”,\”{12}\”,\”{13}\”,\”{14}\”,\”{15}\”,\”{16}\”
user1.Name, profile[“first_name”], profile[“last_name”], profile.Email, profile[“user_type”], profile[“title”], profile[“industry”], profile[“job_title”], profile[“company_name”],
profile[“street_address”], profile[“suburb”], profile[“region”], profile[“postcode”], profile[“country”], profile[“tel_number”],
profile[“purchase_type”], profile[“subscribed”]);
} else
DoLog(“User is null”);
} else
DoLog(“users are null”);
public void WriteToCSV(StringBuilder sb) {

string appPath = Request.PhysicalApplicationPath;
string filePath = appPath + “stringbuilder.csv”;

//stringbuilder to physical csv file
using(StreamWriter swriter = new StreamWriter(filePath)) {

public void DoLog(string message) {
Response.Write(message + ”


Once you browse to this page in a browser you will have CSV file in the specified directory. In the next section I will explain how you can migrate this users’ custom properties to you new sitecore environment


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s