我正在使用NHibernate作为我的数据库层和Fluent NHibernate来为它生成映射,当我为其中一个映射指定引用的自定义表名时,我遇到了麻烦(可能是一个错误?) .

我想从我的 Contract 类映射 IDictionary<SpecimenInformation, int> ,所以我这样做:

class ContractMap : ClassMap<Contract>
{
    public ContractMap()
    {
        // ...
        HasMany(x => x.CustomPrices)
                .Table("ContractCustomPrices")
                .AsEntityMap()
                .Element("CustomPrice", x => x.Type<Int32>());
            // ...
    }
}

它映射得恰到好处,我的架构创建正常,下次我执行 SchemaValidator.Validate() 它按预期传递,但我的所有表都用MixedCase命名,这个表名为 contractcustomprices ,虽然它不影响我程序的功能,它看起来不太好看 . 所以我试过了

HasMany(x => x.CustomPrices)
    .Table("\"ContractCustomPrices\"")
    .AsEntityMap()
    .Element("CustomPrice", x => x.Type<Int32>());

并且我的架构是正确创建的(使用具有正确命名情况的表ContractCustomPrices),但是,下次我启动我的应用程序(验证架构是否正确)时,它会报告 Missing table name: "ContractCustomPrices" . 我再次检查我的数据库,并且表ContractCustomPrices存在(具有正确的情况) . 我试着告诉Fluent NHibernate架构(公共),它没有用 .

知道会发生什么吗?我正在使用NHibernate 3.3.2GA,Fluent NHibernate 1.3-33和PostgreSQL 9.2

Update

这是pgAdmin显示的表中的SQL:

CREATE TABLE "ContractCustomPrices"
(
  contract_id uuid NOT NULL,
  customprice integer,
  specimeninformation_id uuid NOT NULL,
  CONSTRAINT "ContractCustomPrices_pkey" PRIMARY KEY (contract_id, specimeninformation_id),
  CONSTRAINT fk6de9301dca7ae6f1 FOREIGN KEY (contract_id)
      REFERENCES "Contract" (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk6de9301de1a1f00b FOREIGN KEY (specimeninformation_id)
      REFERENCES "SpecimenInformation" (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE "ContractCustomPrices"
  OWNER TO postgres;