Error when trying to access create page for custom content

Topics: Writing modules
Jul 19, 2013 at 4:05 PM
I have created a custom content type via migration as per this tutorial: http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-8

I've followed it to the point where I think I should be able to create some of my new custom items. The table structure is there, I see them in the admin, and the new 'Client' type I've created is in the content list menu. When I try to create a new one however, I get this error:
The model item passed into the dictionary is of type 'Orchard.UI.Zones.ZoneHolding', but this dictionary requires a model item of type 'TestModule.Models.ClientPart'.

Line 757:            var adjustedViewContext = new ViewContext(Html.ViewContext, Html.ViewContext.View, adjustedViewData, Html.ViewContext.TempData, Output);
Line 758:            var adjustedHtml = new HtmlHelper(adjustedViewContext, new ViewDataContainer(adjustedViewData));
Line 759:            adjustedHtml.RenderPartial(TemplateName);
Line 760:        }
Line 761:
And here's all the code making it happen:
Record and Part:

    public class ClientPartRecord : ContentPartRecord
    {
        public virtual string Name { get; set; }
    }

    public class ClientPart : ContentPart<ClientPartRecord>
    {
        [Required]
        public string Name
        {
            get { return Record.Name; }
            set { Record.Name = value; }
        }
    }
    
Part Handler:

    public class ClientPartHandler : ContentHandler
    {
        public ClientPartHandler(IRepository<ClientPartRecord> repository) {
            Filters.Add(StorageFilter.For(repository));
            Filters.Add(new ActivatingFilter<UserPart>("Client"));
        }
    }

Part Driver:

    public class ClientPartDriver : ContentPartDriver<ClientPart>
    {
        protected override string Prefix
        {
            get { return "Client"; }
        }

        protected override DriverResult Editor(ClientPart part, dynamic shapeHelper) {
            return ContentShape("Parts_Client_Edit", () =>
                                                     shapeHelper.EditorTemplate(TemplateName: "Parts/Client"));
        }

        protected override DriverResult Editor(ClientPart part, IUpdateModel updater, dynamic shapeHelper) {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
    
The editor template (/Views/EditorTemplates/Parts/Client.cshtml)

    @model TestModule.Models.ClientPart
           
    <fieldset>
        <div class="editor-label">@Html.LabelFor(x => x.Name)</div>
        <div class="editor-field">
        @Html.EditorFor(x => x.Name)
        @Html.ValidationMessageFor(x => x.Name)
        </div>
    </fieldset>
    
The migration:

    // Creating table ClientPartRecord
    SchemaBuilder.CreateTable("ClientPartRecord", table => table
        .ContentPartRecord()
        .Column("Name", DbType.String)
    );

    ContentDefinitionManager.AlterPartDefinition("ClientPart", part => part
                .Attachable(false));

            ContentDefinitionManager.AlterTypeDefinition("Client", type => type
        .Creatable()
                .WithPart("ClientPart")
                .WithPart("UserPart"));

Placement.info (not sure if needed?)
<Placement>
  <Place Parts_Client_Edit="Content:0" />
</Placement>
Have I missed something critical? I did have a number of silly typos but those I fixed. I am using 1.7RC.
Developer
Jul 19, 2013 at 4:40 PM
Yes, look at your driver's first Editor method:
protected override DriverResult Editor(ClientPart part, dynamic shapeHelper) {
            return ContentShape("Parts_Client_Edit", () =>
                                                     shapeHelper.EditorTemplate(TemplateName: "Parts/Client"));
        }
The EditorTemplate shape requires another property called "Model". Set it to your part:
protected override DriverResult Editor(ClientPart part, dynamic shapeHelper) {
            return ContentShape("Parts_Client_Edit", () =>
                                                     shapeHelper.EditorTemplate(TemplateName: "Parts/Client", Model: part));
        }