Avoiding break of cms project starting

Zuf
Zuf
Vote:
 

I try to change a page property type from string to XhtmlString.

I know this gives InitializationException for the CMS (in some cases e.g. Pages and not Blocks).

-----------------------------------------------------------------------------------------------------------

InvalidCastException: Unable to cast object of type 'System.String' to type 'EPiServer.Core.XhtmlString'

----------------------------------------------------------------------------------------------------------

Is there anyway to force cms to start up and ignore InvalidCastException?

We are on Optimizely 12

Br. Zuf

#331888
Edited, Oct 24, 2024 5:59
Vote:
 

Hi Zuf,

Actually, when you change property then content model is synchronized to database to update the change as well. And converting data from string to xhtml string is need to run. 

You can rename propery name in case of changing property type to incompatitive type. It is simple way to solve this issue.

#331904
Oct 24, 2024 14:12
Vote:
 

You can try using MigrationStep with RenameProperty function to migrate the content from string to XHtmlString.

#331913
Oct 24, 2024 18:15
Zuf
Vote:
 

thanks for your answers.

@Sujit, as far as i understand the MigrationStep only works for renaming and not for changing type?

Br.

Zuf

#331958
Oct 25, 2024 10:50
Sujit Senapati - Oct 29, 2024 23:43
You are right @Zuf. MigrationStep wont work for this. I believe the only solution is to Create a new property with XhtmlString and then migrate the data from String property using a one time migration script. And then remove the property from code and Edit UI.
Vote:
 

Create a new xhtmlstring property, then write code to update the XhtmlString-property from the string property, and finally remove the string property.

#331970
Oct 25, 2024 21:15
* 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.