PropertyDefinitionComparer null reference in Model Sync Initialisation

Vote:
 

Our client has encountered a problem where they receive a null referene expection each time the application starts. Please find the exception below. Looking at the error you can see that this is happening in the ModelSync Initialisation module. It is then tripping up on the Property Definition Comparer. 

So you'd hazard a guess that there's a mismatch between a property type in the model and what is defined in the database. This is the module that presumably updates the database with the page type definitions. Taking a high level approach we attempted to see if there were any suspicious page types or properties in the database that might have got tripped up. We also tried comparing the latest changes in the code to see if we could narrow it down that way. No luck.

So I started reflecting the code and could see there is a Load method which is loading the property from the DB that can potentially return null. This load property is then compared against the current one, without checking for null. This is the snippet from EPiServer.DataAbstraction.DefaultPropertyDefinitionRepository.Save

         PropertyDefinition otherPropertyDefinition = this.Load(propertyDefinition.ID, false);
        if (new PropertyDefinitionComparer().IsEqual(propertyDefinition, otherPropertyDefinition))
        {
            return;
        }

Somehow, we have a case where this module tries to load a property from the DB that it expects to be there. That's as far as I got though and can't seem to figure out wehre this propertyDefinition ID comes from in the first place. 

Is this a known issue? Does anyone know how we could go about finding where this troubled property is? 

[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.DataAbstraction.RuntimeModel.PropertyDefinitionComparer.IsEqual(PropertyDefinition propertyDefinition, PropertyDefinition otherPropertyDefinition) +15
   EPiServer.DataAbstraction.DefaultPropertyDefinitionRepository.Save(PropertyDefinition propertyDefinition, Boolean forceCacheClear) +201
   EPiServer.DataAbstraction.RuntimeModel.PropertyDefinitionSynchronizer.UpdatePropertyDefinition(PropertyDefinitionModel model) +212
   EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelRegister`2.CommitProperties(Boolean deleteUnusedTypes) +739
   EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelScanner`3.Sync(Boolean commitChanges) +150
   EPiServer.Initialization.ModelSyncInitialization.Initialize(InitializationEngine context) +454
   EPiServer.Framework.Initialization.ModuleNode.Execute(Action a, String key) +63
   EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +719
   EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +168
   EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +311
   EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +104
   EPiServer.Global..ctor() +110



#90855
Sep 19, 2014 10:04
Vote:
 

Hi Damien,

Yes, this is a mismatch between the model's properties and the property definitions stored in the database. Unfortunately we can't get to the actual property which causes this, unless we decompile the EPiServer assembly and debug it. Usually this can be fixed in two ways:

1. Restart the IIS to trigger model synchronization again, this should fix the error in most cases.

2. If the IIS reset doesn't fix the issue, you can manually delete the content type and its associated properties from the database, and restart the site again (Do this only if there isn't any content of this type inside the database. If you have contents already created, you need a different method to keep the contents).

Use this script to identify the pkId of the content type:

SELECT * FROM tblContentType

Use this script to delete the content type and its property definitions:

DELETE FROM tblPropertyDefinition WHERE fkContentTypeID = <<your_content_type_pkId>>
DELETE FROM tblContentTypeDefault WHERE fkContentTypeID = <<your_content_type_pkId>>
DELETE FROM tblContentType WHERE pkID = <<your_content_type_pkId>>

Cheer

#174241
Jan 23, 2017 8:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.