NHibernate Mapping Reference without foreign key

I have something similar to this mapping situation in NHibernate:

ClassA mapping.Id(x => x.Id).Column("rowid").GeneratedBy.Identity().Unique(); ClassB mapping.Id(x => x.Id).Column("rowid").GeneratedBy.Identity().Unique(); mapping.References<ClassA>(x => x.ClassA).Nullable(); 

When NHibernate generates a database schema, it creates a foreign key between these tables, even if I specified the "Nullable" attribute in the mapping declaration. It's a shame if I try to save my objects, I get a foreign key constraint error and if I manually delete the foreign key from the database, it works like a charm.

How do I tell NHibernate not to create a foreign key script in this situation?

+4
source share
1 answer

I think you should use the foreign-key="none" attribute in your hbm.xml mapping hbm.xml .

+5
source

Source: https://habr.com/ru/post/1434309/