Question

I want to add new content item in my existing custom module. I want to create new table and manage new content item. I have create new UpdateForm method but this is not call when module enable or disable.

public int UpdateForm2()
    {
        SchemaBuilder.CreateTable("SMRecord", table => table
            .ContentPartRecord()
            .Column<string>("Name", col => col.WithLength(250))
             .Column<decimal>("week1", col => col.WithPrecision(18).WithScale(2))
             .Column<decimal>("week2", col => col.WithPrecision(18).WithScale(2))
             .Column<decimal>("week3", col => col.WithPrecision(18).WithScale(2))
            .Column<int>("SPRecord_Id")
            .Column<bool>("IsActive", col => col.WithDefault(true))
        );
        ContentDefinitionManager.AlterTypeDefinition("SM", builder => builder
                .DisplayedAs("SM")
                .WithPart("SMPart")
                .WithPart("CommonPart")
                .WithPart("IdentityPart")
            );
        ContentDefinitionManager.AlterPartDefinition(typeof(SMRecord).Name, cfg => cfg
            .Attachable());
        return 3;
    }

but UpdateForm2 is not calling. Please help me how to call UpdateForm2 method and upgrade my module version.

Était-ce utile?

La solution

I have moved code UpdateForm1() to Create() method and move UpdateForm2() to UpdateForm1() and update the table Orchard_Framework_DataMigrationRecord currnet module entry. I have done version -1 of current version(CModule.SM.Migrations = 1 instead of CModule.SM.Migrations = 2).

And then run project again. Update link appear in module list. Then disable and enable module. Module will be updated.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top