Mysql 在fluent nhibernate中使用SchemaUpdate时创建的重复/冗余索引

Mysql 在fluent nhibernate中使用SchemaUpdate时创建的重复/冗余索引,mysql,nhibernate,c#-4.0,fluent-nhibernate,foreign-keys,Mysql,Nhibernate,C# 4.0,Fluent Nhibernate,Foreign Keys,我在C#应用程序中使用Fluent NHibernate。该应用程序在启动时执行SchemaUpdate(config)。执行(false,true) 除了在每次启动时都在外键上重新创建索引外,这种方法工作得很好。例如,我有一个表tblpmr,其中有pkkeyid、fkscript\u id、fknumber,每个表都有一个(自动创建的)索引 在空数据库上启动应用程序,表/键/索引创建良好。第二次启动应用程序,除了前面提到的索引之外,我还有script\u id\u 2和number\u 2,第

我在C#应用程序中使用Fluent NHibernate。该应用程序在启动时执行
SchemaUpdate(config)。执行(false,true)

除了在每次启动时都在外键上重新创建索引外,这种方法工作得很好。例如,我有一个表
tblpmr
,其中有pk
keyid
、fk
script\u id
、fk
number
,每个表都有一个(自动创建的)索引

在空数据库上启动应用程序,表/键/索引创建良好。第二次启动应用程序,除了前面提到的索引之外,我还有
script\u id\u 2
number\u 2
,第三次运行应用程序,我还有
script\u id\u 3
number\u 3
等索引

查看NHibernate的日志,我有以下内容:

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)
看起来它无法找到作为表元数据一部分的现有外键,并且作为创建新外键的一部分,它还为它添加了一个索引(副本)

我尝试过使用MyISAM和InnoDB表类型,但没有区别

MySQL服务器5.0.51a-24+lenny5
MySQL连接器/NET6.4.4
流利的NHibernate1.3.0.717
NHibernate3.2.0.4000

我相当肯定,如果它能“找到”外键,那么它将解决问题,但我不知道为什么它不能。我将把mysql服务器升级到当前的最新版本,看看是否有帮助


我找到了,但不确定它是否相关。

似乎是MySQL 5.0没有提供(足够的)外键所需信息的问题。现在在MySQL5.1.49-3(Debian)上运行良好

要是我上周就知道了


注意:在MySQL 5.1(或我认为更新的版本)上,引擎必须是InnoDB,使用MySQL 5.0或MyISAM(甚至在5.1上)会重现此问题。

最明显的是信息模式的is
改进。MySQL 5.1在其元数据数据库中提供的信息比MySQL 5.0中提供的信息多得多
——信息模式包含关于外键的信息以及其他信息……在5.7.11、InnoBB、.net、fluent nhibernate上,我仍然存在同样的问题。还有什么建议吗?