Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6877089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:33:29+00:00 2026-05-27T04:33:29+00:00

I am using Fluent NHibernate in a C# app.The app performs a SchemaUpdate(config).Execute(false, true)

  • 0

I am using Fluent NHibernate in a C# app.The app performs a SchemaUpdate(config).Execute(false, true) on startup.

This works fine with the exception that it re-creates indexes on foreign keys on every start. For example I have a table tblpmr which has the pk keyid, fk script_id, and fk number with an (automatically created) index for each.

Launch the app on an empty DB and the tables/keys/indexes are created fine. Launch the app a second time and in addition to the previously mentioned indexes I have script_id_2 and number_2, run the app a third time and I have indexes script_id_3 and number_3 etc.

Looking at the logs from NHibernate I have the following:

INFO|NHibernate.Dialect.Schema.ITableMetadata|table found: proscript.tblpmr
INFO|NHibernate.Dialect.Schema.ITableMetadata|columns: keyid, is_private, itemref, date, endtext, label, drug, qty, time, doctor, dispensed, cost, dendorse, xml, hostname, script_id, number
INFO|NHibernate.Dialect.Schema.ITableMetadata|foreign keys: 
INFO|NHibernate.Dialect.Schema.ITableMetadata|indexes: primary, script_id, number
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table scriptList add index (patient_id), add constraint FK64CEF4C96630C63A foreign key (patient_id) references tblpatients (number)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table scriptList add index (home), add constraint FK64CEF4C9F35E7604 foreign key (home) references tblhomes (hnumber)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table scriptList add index (box), add constraint FK64CEF4C97558FD5E foreign key (box) references boxList (boxid)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table scriptLog add index (script_id), add constraint FK1C14488375FD47E6 foreign key (script_id) references scriptList (script_id)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table tblpatients add index (home), add constraint FKD51976E2F35E7604 foreign key (home) references tblhomes (hnumber)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table tblpmr add index (script_id), add constraint FKF9AD750975FD47E6 foreign key (script_id) references scriptList (script_id)
DEBUG|NHibernate.Tool.hbm2ddl.SchemaUpdate|alter table tblpmr add index (number), add constraint FKF9AD750967947BA8 foreign key (number) references tblpatients (number)

It looks like it cannot find the existing foreign keys as part of the table metadata and as part of creating the new foreign keys it also adds an index for it (the duplicate).

I have tried using both MyISAM and InnoDB table types with no difference.

MySQL Server 5.0.51a-24+lenny5
MySQL Connector/NET 6.4.4
Fluent NHibernate 1.3.0.717
NHibernate 3.2.0.4000

I am fairly certain if it can ‘find’ the foreign keys then it will fix the problem but I have no idea why it cannot. I will upgrade mysql-server to whatever the current latest version is to see if that helps.

I found https://forum.hibernate.org/viewtopic.php?t=948998 but am unsure if it is related.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:33:29+00:00Added an answer on May 27, 2026 at 4:33 am

    Appears to be an issue with MySQL 5.0 not providing (enough of) the information needed about foreign keys. Working fine now on MySQL 5.1.49-3 (Debian).

    If only I had figured that out last week…

    Note: The engine must be InnoDB on MySQL 5.1 (or newer I assume) using either MySQL 5.0 or MyISAM (even on 5.1) reproduces the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using NHibernate/Fluent NHibernate in an ASP.NET MVC app with a MySQL database.
I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have
I'm working on putting together a simple POC app using Fluent NHibernate to attempt
I'm using Fluent NHibernate in order to auto map my entities. This is the
I am using Fluent NHibernate and having some issues getting a many to many
I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file. Following is the configuration
I'm using Fluent NHibernate auto mapping. I need to access more than one database
I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in
Currently I'm using Fluent NHibernate to generate my database schema, but I want the
I'm using Fluent NHibernate and need to get my Connection String from the connection.connection_string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.