Remove meta field for duplicate name in DXC environment [11.5.1]

Vote:
 

We are in the process of developing our first implementation in DXC. In the past we have hosted everything on promise and are used to having more access to the database/servers. This allowed us to run scripts manually when we need to clean data, or make large changes. The DXC environment is a bit of a different animarl andm we have created a data project with Entity Framework for custom tables, and kept all SQL run as Entity Framework migrations as Johan suggested.

This has worked well until we needed to change a property type in one of our commerce models.

Our EF migrations do not run until after Episerver Framework Initilization runs which results in us receiving the dreaded "A meta field with the same name as the property 'XYZ' exists, but has another data type" error.

  • Is there a sure fire way to run our migrations before the Episerver Framework Initialization starts and is this the best way to handle these issues
  • or should we run cleanup scripts manually in DXC Integration and pass along any scripts that need to run in Preproduction/Production to the DXC team?
#190782
Apr 16, 2018 21:06
Vote:
 

There is no way - at least officially - to run code before the initialization modules. However the problem as I see it is that you are having inconsistent data model. You did not copy the entire error message, but you seem to have two properties in two different content types with same name, but different types. That should be corrected. 

#190784
Apr 16, 2018 21:33
Vote:
 

Quan,

Correct The complete error message:

A meta field with the same name as the property 'PrimaryImage' exists, but has another data type. Property type: ShortString. Meta field type: URL.
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.CreateOrUpdateMetaField(MetaClass metaClass, PropertyDefinitionModel propertyDefinitionModel)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.AssignModelPropertiesToMetaClass(MetaClass metaClass, IEnumerable`1 propertyDefinitionModels)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogContentScannerExtension.AssignValuesToProperties(ContentTypeModel contentTypeModel)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.AssignValuesToProperties(ContentTypeModel modelType)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.AddModel(Type type)
   at EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeModelScanner.RegisterModels()
   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()

We can fix this by running a sql script, but are looking for the best way to do this going forward with the DXC environment. Hopefully this won't happen often and it should only be during our main development. I was mostly wondering if there is a best practice when handling this situation in restricted environments.

#190785
Apr 16, 2018 21:37
Vote:
 

You can go to Commerce Manager and delete the metafield manually. The catalog content type will be re-synchronized when you restart the site.

Of course if you want to keep the data in that metafield, it will be tricky. In such case you'd have to contact developer support service - I'm not allowed to say the trick here. 

#190787
Edited, Apr 16, 2018 21:55
Vote:
 
<div class="blockQuote"> <div class="borderBottom"><a href="/forum/developer-forum/Episerver-Commerce/Thread-Container/2018/4/remove-meta-field-for-duplicate-name-in-dxc-environment-11.5.1/reremove-meta-field-for-duplicate-name-in-dxc-environment-11-53-1/">Quan Mai said:</a></div> <p>You can go to Commerce Manager and delete the metafield manually. The catalog content type will be re-synchronized when you restart the site.</p> <p>Of course if you want to keep the data in that metafield, it will be tricky. In such case you'd have to contact developer support service - I'm not allowed to say the trick here.&nbsp;</p> </div> <p>Quan,</p> <p>We won't be able to go in to Commerce Manager on DXC and force a site restart in Preproduction and Production on DXC though correct? This would also result in errors when the site first starts, which the client probably wouldn't like.</p> <p>Given your response about Develper support service, this leads me to believe we should create scripts on ask them to include them during&nbsp;migrating.</p> <p>I was hoping for some other options that people are using, like maybe creating another Commerce database project used only for Entity Framework migrations.</p> <p>Also what trick?&nbsp;<img src="/Scripts/tinymce/plugins/emoticons/img/smiley-laughing.gif" alt="laughing" /></p>
#191084
Apr 19, 2018 19:43
Vote:
 

"That" trick.

Sometimes when you have faulty data, direct data manipulation is needed, but that should not be done without a close examination of data.

#191100
Apr 20, 2018 7:15