Having own generator in Firebird DB called GEN_PATIENT_ID
I would like to leave the generation of ID on the DB side instead of NHibernate and FluentNHibernate. Following this link I am overriding the default Fluent behavior like this:
public class PatientOverride : IAutoMappingOverride<Patient>
{
public void Override(AutoMapping<Patient> mapping)
{
mapping.Cache.ReadOnly().Region("LongTermReadWrite");
mapping.Id(x => x.Id).GeneratedBy.Sequence("GEN_PATIENT_ID");
mapping.HasOne(patient => patient.Tag).Not.LazyLoad().Cascade.All();
}
}
However I still get an error because NHibernate is trying to generate its own:
{"Dynamic SQL Error\r\nSQL error code = -204\r\nTable unknown\r\nHIBERNATE_UNIQUE_KEY\r\nAt line 1, column 42"}
Doublechecked if I am importing the overrides and it should be OK:
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
the save is pretty much standard:
var patient = patientDtoMapper.MapFrom(patientDto);
using (ITransaction t = NHibernateSession.Current.BeginTransaction())
{
patientRepository.Save(patient);
t.Commit();
}
Any ideas?