Apr 5, 2011 at 10:21 AM
Edited Apr 5, 2011 at 10:28 AM
If you need to alter ContentPart, you'll have to use 'AlterPartDefinition':
ContentDefinitionManager.AlterPartDefinition("mypart", part => part.WithField("MyField", field => field.OfType("ImageField"));
[edit: there was a mistake in the code, I forgot to set up a field type, gave only FieldName. Default fieldType is TextField]
Your code tries to add a part (not field) named 'ImageField' to contentType 'Profile'. That does not work because there is no ContentPart with such name.
The tricky thing is if you want to add a field directly to a ContentType. The web-interface allows it, but 'behind the scene' a fake contentPart is created with the same name as ContentType and the field is actually added to this part. The migration interface
does not seem to support 'fields directly in ContentTypes', so you'll have to create a part and add field to this part.
[Actually I did not try 'fields in types' myself, so I can be wrong about it]