Tyler Wright
Tyler Wright

Reputation: 825

NHibernate: Self Referencing Many to Many configuration issue

I'm trying to understand why I'm getting this error:

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

I have a Client Entity that contains these properties:

    public virtual Iesi.Collections.ISet ChildClients
    {
        get
        {
            return this._ChildClients;
        }
        set
        {
            this._ChildClients = value;
        }
    }

    public virtual Iesi.Collections.ISet ParentClients
    {
        get
        {
            return this._ParentClients;
        }
        set
        {
            this._ParentClients = value;
        }
    }

When I try to fluently configure my mappings, I'm getting the error listed above. This is my mapping for those properties:

HasManyToMany<Client>(x => x.ChildClients)
          .Access.Property()
          .AsSet()
          .Cascade.None()
          .LazyLoad()
          .Inverse()
          .Not.Generic()
          .Table("ParentClients_ChildClients")
          .FetchType.Join()
          .ChildKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1")
                                                               .Nullable())
          .ParentKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId")
                                                               .Nullable());
HasManyToMany<Client>(x => x.ParentClients)
          .Access.Property()
          .AsSet()
          .Cascade.None()
          .LazyLoad()
          .Not.Generic()
          .Table("ParentClients_ChildClients")
          .FetchType.Join()
          .ChildKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId")
                                                               .Nullable())
          .ParentKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1")
                                                               .Nullable());

I'm trying to figure out my issue and why it is happening. What am I doing wrong here?

Upvotes: 0

Views: 892

Answers (1)

Tyler Wright
Tyler Wright

Reputation: 825

Solved here! The issue seems to be with fluent nhibernate validator or something. Wish I knew why this fixed it.

Upvotes: 1

Related Questions