Skip to content

MappingByCode discriminator column with string type throws exception #2717

@SamerX

Description

@SamerX

I am using ConventionModelMapper to map my entities, I am using a table per hierarchy strategy to map two entities with a shared parent. When I try to map the discriminator column to type string, it fails:

mapper.Class<NotificationChannel>(
    m =>
    {
        m.Table("notificationchannels");
        m.Discriminator(
            x =>
            {
                x.Column("discriminator");
                x.Type(NHibernateUtil.String);
            });
    });

Error: No parameterless constructor defined for type 'NHibernate.Type.StringType'.

I tried a lot of ways to make this work but nothing worked. The only way out for me is to map it as a numeric value as it seems the default is a numeric type.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions