
Next month Umbraco V8 will be end of life. This doesn't mean your website will no longer run but it does mean that there are no more (security) updates for V8. So in that sense time is ticking folks.
I've done a few migrations in the past and they always came with a content freeze because of updating the database before going live. Over the past year, I’ve used a little automation to ensure I could repeat this process many times.
In this post, I’ll share some tips on how you can use a little automation to do your V8 upgrades. In my case I upgrade to V13 since my clients go from LTS to LTS versions of Umbraco. The same approach should work for upgrading to V15 as well.
Before we start
Upgrading your V8 to one of the latest versions (either v13 or further) should not be taken lightly since it not only means Upgrading Umbraco. It also means that you need to upgrade from .NET Framework to .NET core as well. A lot of posts can be found about this topic but this means you need to check and refactor all of your existing code. The compiler will tell you when you are almost done....
Automating the Database upgrade
Besides the code changes we need to upgrade the database as well and usually this is the first task. This is the part we can easily automate. The database upgrade comes in two steps
- Upgrade to V10
- Upgrade to V13
This means we need to create a V10 site, run the installer change the connectionstring to the V8 database, run the upgrader and then do the same for the V13 site.
For some reason there is also always some corrupt data , or a login from an old agency that needs to be changed. Doing this multiple times is not only boring, it can also leads to forgotten steps.
Powershell to the rescue (again)
For the migration process I created 3 Powershell scripts.
- Script that creates an empty Umbraco V10 site
- Script that creates an empty Umbraco V13 site
- Script that copies custom modifications to both V10 and V13 site
If we put this into a diagram it should look like this.

What does this mean
The first two scripts will simply create a website that can be used for the conversion of the database.
The last script is more interesting. This adds some functionality by copying some extensions from the Mods folder to the V10 and V13 sites.
#Set Variables
$v10sitename = "Convert10Site"
$v13sitename = "Convert13Site"
$v10migrationfolder = "F:\temp\ConvertV10\"
$v13migrationfolder = "F:\temp\ConvertV13\"
#Folder locations
$currentFolder = (get-location).path
$v10Folder = $(($v10migrationfolder)+($v10sitename))
$v13Folder = $(($v13migrationfolder)+($v13sitename))
Set-Location $v10Folder
#Copy mod files to the V10 convert site
Copy-Item -Path $(($currentFolder)+'\V10\Mods') -Destination ($v10Folder) -Recurse
Set-Location $v13Folder
#Copy mod files to the V13 convert site
Copy-Item -Path $(($currentFolder)+'\V13\Mods') -Destination ($v13Folder) -Recurse
Set-Location $currentFolder
Write-Host "Migration sites are updated, update connectionstring to the V8 database and run both sites in visual studio (v10) first"
In this case it is only a notification handler that resets the admin credentials to something I can remember but I've also added notification handlers that ran some SQL to remove orphan nodes, or cleared the recycle bin. Any repetitive database task goes into a notification handler...
Running the website with this code included makes sure all custom migrations are executed.
What else
If you've built custom extensions, migration can be even more difficult since an extension can use NuGet packages that no longer exist. I usually leave them out in the first few attempts of the migration and Bookmark the code that needs attention afterwards so it is not forgotten.
Source code
If you want to try this yourself for your next Upgrade. The "Source code" can be found on GitHub
Happy Upgrading!