fluent-nhibernate

Fluent Mappings


If you have a PK Column that is not generated in any way how is it mapped?

I assumed it would be something like:

Id(x => x.PKId).Column("PKId");

But I keep getting a: Cannot insert the value NULL into column 'PKId', table 'X.dbo.DBTable; column does not allow nulls. INSERT fails.


Solution

  • Id(x => x.Id)
      .Column("PersonId")
      .GeneratedBy.Assigned();
    

    Taken from here, paragraph "Id".