What should I consider when choosing which identity generator to use with NHibernate?
E.g. a simple fluent mapping:
Id(c => c.ID).GeneratedBy.HiLo("User");
Map(c => c.Username).Not.Nullable().Length(50);
Map(x => x.Password).Not.Nullable().Length(40);
with this POCO:
public class User
{
public virtual long ID { get; private set; } // This could be changed to GUID etc
public virtual string Username { get; set; }
public virtual string Password { get; set; }
public User ()
{
}
}
Should this use HiLo, uuid.hex, HiLoseq etc… And why?
a resource i’ve used when making my decision (I went with HiLo, which is what’s usually recommended, as far as I could see).
this guy likes GUID better.
I think in the end it boils down to personal preference.
The only thing everyone agreed on is NOT to use Identity (especially if you’re using SQL server, because then you’ll exhaust your ids after a few 100Ks records…)