fluent-nhibernate
fluent-nhibernate copied to clipboard
GeneratedBy.Increment() forbidden for strings
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