Nick
Nick

Reputation: 19664

Fluent Nhibernate Generates Invalid column names in One-to-Many

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

Upvotes: 1

Views: 2313

Answers (1)

Nick
Nick

Reputation: 19664

The following appears to be the solution:

.KeyColumnNames.Add("CustomerName") 

-Nick

Upvotes: 4

Related Questions