0
votes

I am trying to to map a many to many relationship using Fluent NHibernate.

I have a table User and a second table Organization. The association table is UserOrganization which contains the UserId and OrganizationId. The UserOrganization table also contains a few other fields (YearBegan, YearEnd).

How would I go ahead and map those using fluent mapping.

Thanks

1

1 Answers

0
votes

You should probably make UserOrganization its own entity that contains those fields. That also gives you more flexibility in terms of cascading updates and deletes.

public class UserOrganization {
    public virtual User User { get; set; }
    public virtual Organization Organization { get; set; }
    public virtual DateTime YearBegan { get; set; }
    public virtual DateTime YearEnd { get; set; }
}