|Number of votes:||6|
We are releasing an update to CMS that contain database schema changes, since this will be the first time we release schema changes via NuGet I thought I spend some time describing how it works and why we made certain choices. If you are using Commerce and been updating the past weeks you will already be familiar with these commands.
We started some time ago building support for shipping database updates in NuGet packages based on some design principals:
The first thing you notice after applied the latest update is the more helpful error message when you start the site for the first time.
To apply the updates open up the ‘Package Manager Console’ and run the command Update-EPiDatabase:
This command will update database schema for the database defined in the connection string EPiServerDB for CMS (and EcfSqlConnection for Commerce), the printout shows which files it finds that are potential updates.
The files are by convention:
For troubleshooting, or if you just want to see more details, you can add -Verbose:$true.
Our recommended approach to deploy changes to production is to run Export-EPiUpdates to export the schema changes to a folder that is independent of Visual Studio, this command basically does the same thing as Update-EPiDatabase but dumps the commands into a bat file to make them portable and easy to run in any environment. If you have a look inside that file you will notice a simple command line tool epideploy.exe that used to execute scripts, same tool that is executed when you update Update-EPiDatabase.
You can also run this command on the development site to test it out, if there are no changes nothing will be modified so it’s safe to run multiple times.
A final note. We have discussed building automatic database schema updates into the products but based on the feedback we got early on it was more important to get the simple and controlled semi-automatic approach right first. Maybe based on your feedback and ideas we will get back to this area and offer more automation, let us know what you think.
Note: All of this is documented in the SDK under “Updating EPiServer via NuGet”, including schema changes to configuration which I did not cover in this post.