0

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?

Tyler Wright
  • 795
  • 1
  • 9
  • 28
  • You have to add `ForeignKeyConstraintNames` it does not work without it and I dont know why. Please see working example here: https://github.com/BrandyFx/Grapes/blob/master/src/Brandy.Grapes.FluentNHibernate/TreeEntryMap.cs – hazzik Sep 11 '12 at 14:21
  • Also, probably you have outdated FluentNHibernate (I saw this bug before https://github.com/jagregory/fluent-nhibernate/pull/88 ) – hazzik Sep 11 '12 at 14:24

1 Answers1

1

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

Community
  • 1
  • 1
Tyler Wright
  • 795
  • 1
  • 9
  • 28