Try our conversational search powered by Generative AI!

Initialization fails after upgrad to CMS 12

Vote:
 

Hi!

I have upgraded from CMS 11 to CMS 12 but the project fails on startup:

Category: EPiServer.Framework.Initialization.InitializationEngine
EventId: 0

Initialize action failed for 'Initialize on class EPiServer.Initialization.Internal.ModelSyncInitialization, EPiServer, Version=12.9.3.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.IsNewModelType(PropertyDefinitionModel propertyModel, PropertyDefinitionType modelPropertyType)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.ValidateChangeOfModelType(PropertyDefinitionModel propertyModel, String modelName)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.SetStateForPropertyDefinitionModels(ContentTypeModel model)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.<AnalyzeProperties>b__15_0(ContentTypeModel model)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass33_0`2.<ForEachWorker>b__0(Int32 i)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.AnalyzeProperties()
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.Sync(Boolean forceCommit)
   at EPiServer.Initialization.Internal.ModelSyncInitialization.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

Exception: 
System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.IsNewModelType(PropertyDefinitionModel propertyModel, PropertyDefinitionType modelPropertyType)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.ValidateChangeOfModelType(PropertyDefinitionModel propertyModel, String modelName)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.SetStateForPropertyDefinitionModels(ContentTypeModel model)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.<AnalyzeProperties>b__15_0(ContentTypeModel model)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass33_0`2.<ForEachWorker>b__0(Int32 i)
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister.AnalyzeProperties()
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.Sync(Boolean forceCommit)
   at EPiServer.Initialization.Internal.ModelSyncInitialization.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)
   at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)
   at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

I also find this in the windows log if that could have something to do with it:

Category: EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelRegister
EventId: 0

Changes in the model were ignored because its version(2.4.0.4) is lower than version in the database(58.0).

Ideas what could be causing this? We have also moved page types from a Core project to Features/Pages/Standpage and so on. Could that be a problem?

We also moved some properties tagged with [PropertyDefinitionTypePlugIn] to a different namespace which gave error on startup since the definition TypeName has changed.
I updated the TypeName in the tblPropertyDefinitionType and then that error disapeared. Is that ok or could that cause a problem?

Thanks!

/Kristoffer

#293254
Edited, Dec 16, 2022 13:18
Vote:
 

Hello Kristoffer,

Since you've migrated from CMS 11 to CMS 12, you won't have an AssemblyInfo.cs for your projects anymore that describe the version of the application which is used for the content model for your content types.  The default will essentially be 1.0.0.0 which is indeed lower than 2.4.0.4.  You'll need to make sure the version information is directly within the csproj now.

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AssemblyVersion>0.6.0.0</AssemblyVersion>
    </PropertyGroup>

If you apply a version of 3.0.0.0 to the csproj files does it solve your issue?

I'd make sure that you have a separate development database for CMS 12 just in case you have to support the CMS 11 version during the conversion process.

#293255
Edited, Dec 16, 2022 13:29
Vote:
 

Hi Mark, 

Thanks for the reply. It says that version in database i 58.0. Where should I find the <AssemblyVersion>? I cannot find anything in my .proj files?

/Kristoffer

#293256
Dec 16, 2022 13:40
Mark Stott - Dec 16, 2022 14:34
It won't exist by default, you have to add it. but if you add it in the properties interface it should add it for you.
Vote:
 

I managed to find the problem with 58 so that is gone now but the initialization still fails. Any more suggestions?

#293257
Dec 16, 2022 14:02
Quan Mai - Dec 16, 2022 16:29
is it still same stacktrace?
Kristoffer Lindén - Dec 19, 2022 9:14
@Quan Mai, yes it is still the same stacktrace as above. An error in IsNewModelType().
Vote:
 

Hi!

I can confirm that I can access the edit mode if I connect the database to an empty project using the dotnet new epi-cms-empty command.

So there is something in our solution I guess? 
During the upgrade we have moved all page types and custom properties to new namespaces, could that have something to do with it?

/Kristoffer

#293378
Dec 19, 2022 10:32
Vote:
 

Hi Kristoffer,

This still sounds like the model version for your content items within the database that you're trying to upgrade is 2.4.0.4 while your new CMS build is at 1.0.0.0 which can only be resolved by updating the version of your assemblies.

Lets say you have a content type of StandardPage: when your build pipeline versioned your dlls or the AssemblyInfo.cs of your CMS 11 project had a version of 2.4.0.4.  When creating or updating those content types, the version number that was applied to your dlls at that time is recorded into the Optimizely CMS database alongside the new configuration of the content type.

As part of upgrading to CMS 12 that AssemblyInfo.cs no longer exists as it's not a .NET 5+ thing.  So now your dll is effectively 1.0.0.0.  When the application starts up and tries to migrate property or namespace changes for StandardPage, it will be checking the version numbers assigned to them.  It will be understanding that the database has a 2.4.0.4 version of StandardPage and that the new definition is 1.0.0.0 ... a backwards change, which it will reject.

The new database would work because it does not have v2.4.0.4 of your previously created content types.

#293379
Dec 19, 2022 10:50
Vote:
 

Thanks!

I found AssemblyInfo.cs in two projects containing 2.4.0.4, obvioulsy you can still use AssemblyInfo. I changed to 3.0.0.0 and then everything worked just fine.
Thanks for the guidance Mark!

/Kristoffer

#293392
Dec 19, 2022 14:00
Mark Stott - Dec 19, 2022 15:34
I've versioned my projects within the *.csproj itself which is how the VS UI will do it, but I will keep in mind that it still respects the AssemblyInfo

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.