4

Closed

Codegen datamigration generates wrong table name

description

I've module called "MyModule.Module1" that contains MyCustomPartRecord in Models folder. codegen datamigration <feature name> generates the follwoing code:
public int Create()
{
    SchemaBuilder.CreateTable(
        "MyModule_Module1_MyCustomPartRecord",
        table =>
        table.ContentPartRecord()
             .Column("CreateDate", DbType.String)
             .Column("LastDate", DbType.String)
             .Column("Description", DbType.String));

    ContentDefinitionManager.AlterPartDefinition("MyCustomPart", builder => builder.Attachable());

    return 1;
Unfortunetaly, using such a table produces an error:
could not insert: [MyModule.Module1.Models.MyCustomPartRecord#20][SQL: INSERT INTO MyModule_Module1_MyCustomPartRecord (CreateDate, LastDate, Description, Id) VALUES (?, ?, ?, ?)]
Changing manually table name MyModule_Module1_MyCustomPartRecord to MyCustomPartRecord resolves problem.

Looks that codegen generateS wrong table name.
Closed Jul 23, 2013 at 5:35 PM by pszmyd
Checked with latest 1.x code and migrations are generated correctly. Please reopen if you can repro with the latest code and provide repro steps.

comments

pszmyd wrote Jul 23, 2013 at 5:23 PM

Definitely a bug - the resulting table is prefixed twice - one in the given string, second by the SchemaBuilder.CreateTable().