I'm using SchemaUpdate
to synchronize my hbms
with existing database. Database has recently created based on hbms
and is completely up-to-date. But SchemaUpdate
generates all foreign key constraints again.
For example suppose you have Student
and Teacher
. Student
has association to Teacher
with name ArtTeacher
. ArtTeacher
is a foreign key from Student
to Teacher
. Suppose database is up-to-date and currently holde Student
, Teacher
and their foreign key relation. So HBM
and Database
are equivalent. Know SchemaUpdate
must not do anything but when I see its generated scripts, it re-produce that foreign key again.
Why this happens? Is there any way to avoid it?
The secret is to ensure that you specify names for the foreign keys, or else NHibernate will generate a random name which won't match the existing schema.
(I fished this answer out of the Google Cache of Afshar's blog post).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With