I'm trying to map the following model with Castle ActiveRecord
A contact can belong to several different groups, but does not have to be in a group.
In the database this i represented as:
Contact
Group
Group_Contact - GroupId - ContactId
The contact does not need to know which groups it is contained by (maybe it's a mapping requirement, but not a business requirement).
Ideally I'd like to just have a collection of Contacts on the Group class.
I've tried mapping it like this in the Group class
[HasAndBelongsToMany(typeof(Contact),
Table = "Group_Contact", ColumnKey = "GroupId", ColumnRef = "ContactId")]
public IEnumerable<Contact> Contacts { get; set; }
Which gives me the following exception: Could not guess relation type for property Group.Contacts
Any help is highly appreciated.
Instead of IEnumerable<Contact>
use ICollection<Contact>
(for bag semantics) or ISet<Contact>
(for set semantics) or IList<Contact>