HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Install database schema

Describes how to install a database schema.

Optimizely Content Management System (CMS) uses Microsoft SQL Server to store content and other information created in the system. CMS supports all database editions including SQL Azure. See the System requirements for Optimizely for specific versions of SQL Server that CMS supports.

Install from the Visual Studio integration

A database schema is a way to logically group objects such as tables, views and stored procedures, in the database. When you create a new site from the Visual Studio integration, it automatically creates the database with the CMS schema. Each version of the database schema targets a specific version of the product. The following topics show how to deploy a database from development to production.

Install on an empty database

If you need to install database schema on an empty database, you can use Initialize-EPiDatabase cmdlet from the Package Manager in Visual Studio. The Initialize-EPiDatabase cmdlet installs the database schemas included in the installed NuGet packages.

Enable automatic creation of database schemas

You can also configure a site to automatically create the database schema during site initialization. When the site starts up, Optimizely checks if the schema is installed in the current database as specified by the connection string. If no schema is found and automatic creation is enabled, it executes an SQL script that adds the schema to the database.

To enable automatic schema creation, add attribute createDatabaseSchema="true" to the episerver.framework element in configuration as shown below:

`<episerver.framework createDatabaseSchema="true">`

The automatic schema creation is done using the same process as schema updates and it therefore allows you to interact with the schema creation process by registering an implementation of IDatabaseSchemaValidator in the Optimizely IOC container. See Automatic schema updates for further information and examples. Automatic database schema creation will be available for EPiServer.Commerce in upcoming versions.

Create database manually

If you want to manually deploy the schema, you find the SQL script files in the EPiServer.CMS.Core NuGet package under the tools subfolder.

Install optional database schemas

If the web application was configured to use Windows Workflow Foundation or SQL Membership provider module, you need to deploy the Windows Workflow Foundation and the SQL Membership provider database schema manually. The Initialize-EPiDatabase cmdlet does not install these.

Best practices when you set up the database

Consider the following recommendations:

  • When upgrading, you should never directly access the tables or stored procedures in the database, or create custom tables that interfere with the tables created by CMS. You should always use the documented API instead, because backwards compatibility on the database level is not guaranteed.
  • CMS supports several SQL Server high-availability options for availability and performance of the database, which include fail-over clustering and database mirroring. For instance, database mirroring retrieves a “hot” standby database that operates in read-only mode, and all transactions are copied to the mirror, either synchronously or asynchronously. You can configure instant fail-over using a “witness” server.
  • When you run an SQL Server in production, create a maintenance plan for the database including backup, checking database consistency, and rebuilding indexes. Performance of the database degrades over time if you do not create a maintenance plan, especially if indexes are never rebuilt since the query speed degrades as new content is added. For information, see Maintenance Plans (Microsoft).