SaaS CMS has officially launched! Learn more now.

cms12 database upgrade failed


I setup a local db from a copy from PROD.
In Visual Studio, I setup an Optimizely CMS empty project and set the "EPiServerDB" connection string to this local db.
When running the site I get an error ‘Failed to update database’.

This is the only package in the Project:
<PackageReference Include="EPiServer.CMS" Version="12.26.0" />

Where can I look to see why the db upgrade is failing?

Dec 14, 2023 14:25

Maybe you can add this to your Startup.Configure ?

            if (env.IsDevelopment())

Dec 14, 2023 15:04

I set the LogLevel to Trace for everything and in the Output window I see it trying to apply all of the update scripts.
However, it's trying to do this in 12.8.0.sql

ALTER TABLE [dbo].[tblMappedIdentity]
    ADD [Metadata] NVARCHAR (MAX) NULL,
        [Saved]    DATETIME       NULL;

but my cms11 database already looks like this...

the error:

System.Data.DataException: Failed to update database during execution of statement 'ALTER TABLE [dbo].[tblMappedIdentity]
    ADD [Metadata] NVARCHAR (MAX) NULL,
        [Saved]    DATETIME       NULL;
 ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Column names in each table must be unique. Column name 'Metadata' in table 'dbo.tblMappedIdentity' is specified more than once.
Dec 14, 2023 15:09

I see, it is possible to just drop the two columns and proceed - especially as this is for local development it should not have any consequences.

I will look into this to see if we can do anything about it 

Dec 14, 2023 16:27

I tried your suggestion and removed the two columns. The db upgrade script now gets to 12.8.0.sql and errors trying to create a stored proc.

Microsoft.Data.SqlClient.SqlException (0x80131904): There is already an object named 'netMappedIdentitySetMetadata' in the database.
Dec 14, 2023 18:36

I deleted the stored proc 'netMappedIdentitySetMetadata' and now the db updates finish without an error.

Dec 14, 2023 19:16

Public Bug posted:

Jan 19, 2024 19:44
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.