As developers, we often want to experiment and tinker around with things.  The annoying part of this is that our development databases can often get destroyed or corrupted.  To make life easier, Episerver introduced a quick and easy way for us to create a clean database.  In today's post, I'm going to show you how to create a clean Episerver database and give you some tips to make the restore process less painful.

How to create clean EPiServer database?

The first thing you need to do is create a new empty database in SQL.

In SQL Manager, create a new database, by right-clicking on your database instance and selecting 'New Database'!

Give your database a name and a database owner.

In your website, update your connection string to point to your new database, as shown above:

In your Nuget package console window, you can now type 'Initialize-EPiDatabase'. This will then go off and create a new blank Episerver database!

Updating Your Database To The Right Patchset Version

After creating a database, it is very likely that you will also need to upgrade it to your version of Episerver patchset, this can also be done in Nuget using:

Tips When Rebuilding Your Database

When you reset your database, you will obviously lose all your web pages and site structure. If you don't want to lose your pages, then I suggest you look at the Page Import/Export feature within the Episerver admin.

You have several different back-up options, depending on what you want to restore, when you're ready, click the 'export' button

An XML file should now download to your computer

You can then import the file back into Episerver using the import tab, simple! Following this approach means you have a pretty powerful technique to do work, clear your database and re-import your content easily. Over the years, I've tried several different techniques to achieve a similar goal and by far this is the quickest and easiest approach.