Content Type Record Not Being Generated When I Create a Content Type in Module

Topics: Writing modules
Jul 23, 2014 at 1:40 AM
Edited Jul 23, 2014 at 1:47 AM
I have created a module the creates a custom content part and then in the migration creates a content type and attaches the custom content part to it. The content type shows up to create content items but when I try to save any content items of the new type I get the error:

null id in Orchard.ContentManagement.Records.ContentTypeRecord entry

When I look in the table Orchard_Framework_ContentTypeRecord there is no record for my new content type.

The migration code is:
 public int UpdateFrom4()
        {
            ContentDefinitionManager.AlterTypeDefinition("RBScholar", cfg => cfg
                .Creatable()
                .WithPart("rbScholarProfilePart")
                .WithPart("BodyPart")
                .WithPart("TitlePart")
                .WithPart("CommonPart"));
            return 5;
        }
It seems that when I create a content type from the admin UI after I save the first content item Orchard adds the new content type to the Orchard_Framework_ContentTypeRecord table. This is not happening with the content types I create in the migration.

What am I doing wrong? Do I need to add something to my handler code (see handler code below)?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Environment.Extensions;
using mqual.rbscholar.Models;

namespace mqual.rbscholar.Handlers
{
    public class rbScholarHandler : ContentHandler
    {
        public rbScholarHandler(IRepository<rbScholarProfilePartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }
}
Aug 13, 2014 at 5:01 PM
did you try looking at the error log?

or, perhaps u could try forcing orchard to insert the content type to ContentTypeRecord by doing this :
        var dummy = _contentManager.New("RBScholar");
        _contentManager.Create(dummy);
        _contentManager.Remove(dummy);