views:

361

answers:

1

Hello..

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

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:

<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?

Thanks

+3  A: 

The following appears to be the solution:

.KeyColumnNames.Add("CustomerName")

-Nick

Nick
In version 1.0 it is .KeyColumn("CustomerName") or .KeyColumns.Add("CustomerName").
alex2k8

related questions