fluent-nhibernate
fluent-nhibernate copied to clipboard
Incorrect mapping when having an identity property with a different name than "Id", and the "Id" property which is not an identity column.
When mapping this class:
public class DestinationListItemDto
{
public int DestinationId { get; set; }
public Guid Id { get; set; }
}
public class DestinationListItemDtoMappingOverrides : IAutoMappingOverride<DestinationListItemDto>
{
public void Override(AutoMapping<DestinationListItemDto> mapping)
{
mapping.Id(x => x.DestinationId);
}
}
the generated schema looks like this:
create table "DestinationListItemDto" (
"Id" uuid not null,
primary key ("Id")
);
Which is incorrect - the DestinationId columns is missing. When I add this line into the mapping:
mapping.Map(x => x.Id);
the generated schema looks better:
create table "DestinationListItemDto" (
"DestinationId" serial,
"Id" uuid not null,
primary key ("DestinationId")
);
as the DestinationId column is there. But the column type is serial instead of int. I can live with that, but it's something you might like to look into.
FluentNHibernate 2.1.2