I've just started to play around with Fluent NHibernate and would like some help / pointers on how I got about mapping this. Here's the domain model I'm working with:
Class User: Your standard user class
Class Preference: A set of key value pairs. A user can have many preferences.
Class Post: Omitted complete description for the sake of brevity, but a user creates a post and it can contain one or more preferences.
So, to recap:
class User
{
IList<Preference> Preferences;
IList<Post> Posts;
}
class Post
{
IList<Preference> PostData;
}
Hibernate automapper comes up with the following DB Structure:
User
------------------------
User_Id
Preference
------------------------
Preference_Id | User_Id | Post_Id
Post
------------------------
Post_Id | User_Id
The preference table looks ugly to me and would much rather have something like:
User
------------------------
User_Id
Preference
------------------------
Preference_Id | User_Id
Post
------------------------
Post_Id | User_Id | Preference_Id
Any help on how to do this is much appreciated! I already have a class that implements the IAutoMappingOverride interface, but I'm not sure how to do the actual mapping.
Thanks,
Teja