Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4611482
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:16:26+00:00 2026-05-22T01:16:26+00:00

I am having a problem trying to map out a many-to-many relationship , where

  • 0

I am having a problem trying to map out a many-to-many relationship , where both sides of the relationship reference the same entity. I am using Fluent NHibernate and NH3.1.

Basically, the scenario is this – I have a category, which can have multiple parents. Thus, a category has multiple other categories as parents, as well as multiple other categories as its children.

HasManyToMany(x => x.ParentCategories).AsBag().Table("parentcategorychildren").ParentKeyColumn("ChildID").ChildKeyColumn("ParentID").Cascade.SaveUpdate();
HasManyToMany(x => x.ChildrenCategories).AsBag().Table("parentcategorychildren").ParentKeyColumn("ParentID").ChildKeyColumn("ChildID").Inverse();

However, when I try to build the factory, I get the following error:

The relationship Category.ChildrenCategories to Category.ChildrenCategories has Inverse specified on both sides. Remove Inverse from one side of the relationship.

What I am finding strange is why is it mentioning ‘Category.ChildrenCategories’ to Category.ChildrenCategories, as opposed to ParentCategories?

Any help would be greatly appreciated !

I just created a bounty for this, because it’s important enough to me. Please, I’m not interested in “you can’t do this” as an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:16:27+00:00Added an answer on May 22, 2026 at 1:16 am

    This is most likely a FNH bug and it is most likely already fixed in the latest FNH source code. There is no problem when using FNH1.0 and NH2.1. Equivalent HBM mapping works well in FNH1.2 and NH3.1:

    <bag name="ParentCategories" cascade="all" table="parentcategorychildren">
        <key column="ChildID" />
        <many-to-many column="ParentID" class="Category" />
    </bag>
    
    <bag name="ChildrenCategories" inverse="true" table="parentcategorychildren">
        <key column="ParentID" />
        <many-to-many column="ChildID" class="Category" />
    </bag>
    

    EDIT:
    After digging in FNH source code I found a workaround. Let’s say, your configuration looks like this:

    .Mappings(m => {
        m.FluentMappings.AddFromAssemblyOf<Category>();
    })
    

    The unlucky code can be suppressed by this configuration:

    .Mappings(m => {
        var persistenceModel = new PersistenceModel();
        persistenceModel.AddMappingsFromAssembly(typeof(Category).Assembly);
        persistenceModel.ValidationEnabled = false; // this makes the trick
        m.UsePersistenceModel(persistenceModel);
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a big problem trying to do map an entity to another that
I'm having a problem using the java.text.MessageFormat object. I'm trying to create SQL insert
I'm trying to draw a tile map in C# and the problem I'm having
I am having a weird problem with a simple map application I am trying
I'm attempting to map libpcap using ctypes to python3.2 and I'm having a problem
Having a problem trying to create a function, as part of a BizTalk helper
I am having a problem trying to use the prependTo() function in jQuery... for
I'm having a problem trying to format the output on the jQuery UI datepicker.
I'm having a problem when trying to pass an array back to a COM
I am having problem that when i am trying to submit the form by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.