I\'m trying to map a simple data structure in nhibernate
Tables:
Employees
employeeID int
username varchar(30)
departmentID int
Departm
You need to specify the key column.
HasMany(m => m.Employees).KeyColumn("DepartmentId");
You need to use the KeyColumn method on the HasMany declaration, as explained in the documentation
You may either: create a Fluent NHibernate convention so that the HasMany "foreign key" is created as <'Name'>ID.
Or change the Department mapping:
HasMany(m => m.Employees).KeyColumns.Add("DepartmentID")