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

时间:2022-06-17 20:11:47

Fluent NHibernate Generates invalid columns names within a Many to one relationship.

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();



    }

The resulting HBM:

由此产生的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>

Notice the "Employees_id". I have seen other post where people where using a method "WithKeyColumn("EmployeeID"). This method is unavailable. What can I do?

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

Thanks

1 个解决方案

#1


The following appears to be the solution:

以下似乎是解决方案:

.KeyColumnNames.Add("CustomerName") 

-Nick

#1


The following appears to be the solution:

以下似乎是解决方案:

.KeyColumnNames.Add("CustomerName") 

-Nick