NHibernate uses its own Firebird generator
Having my own generator in Firebird DB called GEN_PATIENT_ID
, I would like to leave the id generation on the DB side, not NHibernate and FluentNHibernate. Following this link, I am overriding the default behavior of Fluent 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 the error because NHibernate is trying to create its own file:
{"Dynamic SQL error error \ r \ nSQL error code = -204 \ r \ nTable unknown \ r \ nHIBERNATE_UNIQUE_KEY \ r \ nIn line 1, column 42"}
Double check if I import overrides and it should be OK:
mappings.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
saving is pretty much standard:
var patient = patientDtoMapper.MapFrom(patientDto);
using (ITransaction t = NHibernateSession.Current.BeginTransaction())
{
patientRepository.Save(patient);
t.Commit();
}
Any ideas?
source to share
No one has answered this question yet
See similar questions:
or similar: