SchemaValidator失败并带有我引用的表名

时间:2013-01-16 20:40:55

标签: c# .net nhibernate fluent-nhibernate

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

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

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

更新

这是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;

0 个答案:

没有答案