How to change content type id?

Topics: Customizing Orchard
Sep 3, 2013 at 9:57 PM
One of my content types has an id that contains a "-" character. This causes the media library picker field to break because the generated javascript also contains a "-" character which is not legal in variable names.

is there any way I can change the content type Id of an existing content type?
Sep 4, 2013 at 12:00 AM
There is, but the easiest way is to delete the type and start over. If you can't do that because you don't want to loose content items, you can change the name by going straight into the database and update the records in the following tables:
  • Orchard_Framework_ContentTypeRecord
  • Settings_ContentTypeDefinitionRecord
And as always, before you do anything, make sure to backup the database first.
Sep 4, 2013 at 2:59 PM
Thanks, will do.
Oct 18, 2013 at 9:54 PM
Edited Oct 18, 2013 at 9:55 PM
I noticed that doing this shunted the ContentType form (let's say "EMailForm") into a ContentPart which was then "attached" to the ContentType for which you changed the name. Basically, it now appeared as EMailForm under "Parts". It seemed like you could still edit the form properties under the new "EMailForm" ContentPart.

A little more digging and I found a change was also needed for:
  • Setting_ContentPartDefinitionRecord
Remember to restart your site so the change takes effect.

After doing this the fields displayed properly in the Content Type under "Fields" as I was used to with Custom Forms.