Fluent Nhibernate在一对多中生成无效的列名称

时间:2009-05-12 02:12:34

标签: nhibernate orm fluent-nhibernate mapping

Fluent NHibernate在多对一关系中生成无效列名称。

enter public EmployeeMap()
    {
        Id(x => x.EmployeeID);
        Map(x => x.FirstName);
        Map(x => x.LastName);
        Map(x => x.City);
        Map(x => x.HireDate);
        Map(x => x.Title);
        HasMany(x => x.Orders)
            .WithForeignKeyConstraintName("EmployeeID")
            .Inverse()
            .Cascade.All();



    }

由此产生的HBM:

<bag name="Orders" inverse="true" cascade="all">
  <key foreign-key="EmployeeID" column="Employees_id" />
  <one-to-many class="FluentWeb.Domain.Orders, FluentWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>

注意“Employees_id”。我看过其他人使用方法“WithKeyColumn(”EmployeeID“)的帖子。这个方法不可用。我该怎么办?

由于

1 个答案:

答案 0 :(得分:4)

以下似乎是解决方案:

.KeyColumnNames.Add("CustomerName") 

-Nick