Error creating Orchard project module: not required: SomePartRecord

I am trying to create a simple setup in Orchard that appears on the settings page. I created a module that adds my ContentPart to the settings page and correctly creates a table in the database, but every time the cshtml file is rendered and access to the recording resource is saved, I continue to receive the next NHibernate record.

Not required: TekFlow.Contact.TekFlowEmailSettingsPartRecord. (TekFlow.Contact is the name of the module)

Below is all the code that I use to create the record / part / handler / driver needed in Orchard.

public class TekFlowEmailSettingsPartDriver : ContentPartDriver<TekFlowEmailSettingsPart> { public TekFlowEmailSettingsPartDriver() { T = NullLocalizer.Instance; } public Localizer T { get; set; } protected override DriverResult Editor(TekFlowEmailSettingsPart part, dynamic shapeHelper) { return ContentShape("Parts_TekFlowEmailSettings_Edit", () => shapeHelper.EditorTemplate(TemplateName: "Parts.TekFlowEmailSettings", Model: part, Prefix: Prefix) ); } protected override DriverResult Editor(TekFlowEmailSettingsPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper) { bool success = updater.TryUpdateModel(part, Prefix, null, null); return Editor(part, shapeHelper); } } [UsedImplicitly] public class TekFlowEmailSettingsPartHandler : ContentHandler { public TekFlowEmailSettingsPartHandler(IRepository<TekFlowEmailSettingsPartRecord> repository) { Filters.Add(new ActivatingFilter<TekFlowEmailSettingsPart>("Site")); Filters.Add(StorageFilter.For(repository)); } } public class TekFlowEmailSettingsPartRecord : ContentPartRecord { public virtual string SendToEmail { get; set; } } public class TekFlowEmailSettingsPart : ContentPart<TekFlowEmailSettingsPartRecord> { public string SendToEmail { get { return Record.SendToEmail; } set { Record.SendToEmail = value; } } } public class TekFlowEmailSettingsDataMigration : DataMigrationImpl { public int Create() { SchemaBuilder.CreateTable("TekFlowEmailSettingsPartRecord", table => table .ContentPartRecord() .Column<string>("SendToEmail", c => c.WithDefault(" SomeEmail@somedomain.com ").WithLength(255)) ); ContentDefinitionManager.AlterPartDefinition( typeof(TekFlowEmailSettingsPart).Name, cfg => cfg.Attachable()); return 1; } } 
+6
c # asp.net-mvc-2 orchardcms
source share
3 answers

It turns out that if your part and record are not in your Model namespace, this will not work in the garden. When I changed the namespace for the two classes, it worked. There must be speculation what Orchard is doing.

+12
source share

I got the same error due to the lack of virtual variables in my record. (In my case, he did not inherit ContentPartRecord and did not declare it as his own Id, not sure if the problem was simply that Id was not virtual or that all variables should be virtual.)

Also, as stated above, your namespace should end with models or records, as described here: https://orchard.codeplex.com/discussions/267968

+1
source share

My Favicon module has almost the same structure, and when I made the file compared to the file, I could not find a significant difference. The only thing that looks suspicious is that you did not define a prefix in your driver. This may affect the ability of the binder to rehydrate the model, but I'm not sure how this will affect persistence.

0
source share

All Articles