Add Episerver site from scratch


Open Visual Studio and create a new Episerver project.

Select Empty Project

After press OK, you will have a new solution with a web project on it.

The connection string to a database is set to a localDb instance. Lets change to a SQL Express.


    <add name="EPiServerDB" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|EPiServerDB_d6814c74.mdf;Initial Catalog=EPiServerDB_d6814c74;Connection Timeout=60;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />


    <add name="EPiServerDB" connectionString="Server=.\\SQLExpress;Database=EpiserverAdventures;Trusted_Connection=True;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />

Add EPiserver Forms to the project. Run on the Package Manager console:

Install-Package EPiServer.Forms -ProjectName EpiserverAdventures

Lets update all the need packages of the project.

Update-Package EPiServer.CMS -ProjectName EpiserverAdventures -ToHighestMinor

After getting the Episerver.Forms need to authentication and updated all the packaged, we can create the database on the SQLExpress that we had configured before.


The database is populated with schema for episerver.

Update the database with latest schema need.


Since we dont want to use Windows authentication to login, we need to change the provider and create a new sql user as administrator for our episerver account.

Add an entry to <appSettings>, as shown in the following markup:

<add key="EpiserverAdventures:RegisterAdmin" value="true" />

Find the element <membership> and set the defaultProvider to SqlServerMembershipProvider, as shown in the following markup:

<membership defaultProvider="SqlServerMembershipProvider" ...

Find the element <roleManager> and set the defaultProvider to SqlServerRoleProvider, as shown in the following markup:

<roleManager enabled="true" defaultProvider="SqlServerRoleProvider" ...

Add a new IInitializableModule module to the project:

using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using System.Configuration;
using System.Web.Security;
namespace AlloyTraining.Business.Initialization
    public class RegisterAdminInitializationModule : IInitializableModule
        private const string roleName = "Administrators";
        private const string userName = "Admin";
        private const string password = "Pa$$w0rd";
        private const string email = "";
        public void Initialize(InitializationEngine context)
            string enabledString =
            bool enabled;
            if (bool.TryParse(enabledString, out enabled))
                if (enabled)
                    #region Use ASP.NET Membership classes to create the role and user
                    // if the role does not exist, create it
                    if (!Roles.RoleExists(roleName))
                    // if the user already exists, delete it
                    MembershipUser user = Membership.GetUser(userName);
                    if (user != null)
                    // create the user with password and add it to role
                    Membership.CreateUser(userName, password, email);
                    Roles.AddUserToRole(userName, roleName);
        public void Uninitialize(InitializationEngine context) { }

Start the site, enter /EPiServer/CMS/, and confirm that you can log in as a CMS admin with the following credentials:

Username: admin

Password: Pa$$w0rd

Close the browser.

Modify or remove the entry in <appSettings> to disable the registration of Admin, as shown in the following markup:

<add key="alloy:RegisterAdmin" value="false" />

3 thoughts on “Add Episerver site from scratch

  1. I have been with Episerver for over 6 months now. While getting started I was looking for information which would resemble something just like this. Nevertheless best I have seen for someone who wants to get started with Epi.


  2. Update RegisterAdminInitializationModule module to create the role Administrators instead of webAdmins. After starting the site, the user created didn’t had the permissions to change the root page. Create on the CMS UI the new role named “Administrators” and add it to the admin user. Therefore, i changed the creation of the role on the module.


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 )

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

%d bloggers like this: