fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

GeneratedBy.Increment() forbidden for strings

Open Orkad opened this issue 4 years ago • 0 comments

Hello Fluent NHibernate Team !

Today i encounter a Fluent NHibernate limitation (not NHibernate). I was trying to map an Id property using : Id(x => x.Id, "STRING_ID").GeneratedBy.Increment() An InvalidOperationException was raised during the configuration build because the expected Id property was not a number. I know this is a weird way to store Id data, but according to nhibernate IncrementGenerator implementation, it is supposed to work.

The workaround is to use the provided NHibernate generator as a custom generator : Id(x => x.Id, "STRING_ID").GeneratedBy.Custom<IncrementGenerator>()

IncrementGenerator is provided by NHibernate in NHibernate.Id namespace

Orkad avatar Nov 12 '21 10:11 Orkad