With NHibernate I no longer expose foreign keys on my domain objects, so Product no longer has a property:
public int CategoryId {get;set;}
but instead has:
public Category Category {get;set;}
Unforunately this doesn't appear to work so well with the automatic model binding in ASP.NET MVC - if I want to simply bind a form collection directly to my domain object.
For example, I couldn't just have a selectlist of Category Id values in my view, accept a product object in my controller action, and expect MVC to convert this into a category object.
My solution so far has been to create view models that do have properties for the foreign key values - However, this normally leads to a fair bit of duplication in code and extra mapping logic in my controller.
Is there a better way?