Many to Many

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
muellermartin43
Posts: 4
Joined: Tue 01 Sep 2020 08:23

Many to Many

Post by muellermartin43 » Tue 24 Aug 2021 12:30

HI

I'm using Entity Developer (nHibernate) and have the case that I have two tables which I want to associate with "many to many".

The problem itself may be a bit more complex, but for the sake of the question I have broken it down to the simplest example imaginable.
By the way, the program in which the model gets implemented is written in C#..

Let's say I have one table that contains users and another table that contains usergroups. So after adding the "many to many" association a user gets the property "UserGroups" and vice versa the user group gets the property "Users".


When I "Update or Create" a user I can assign groups. However, when I edit a group, I cannot assign users to the group.
Later I found out that I can set "inverse" in the association for the other end: The problem still exists but in the other direction.

Unfortunately, in EntityDeveloper you cannot disable "inverse" for both ends (only for one at a time).
I test edited the "xml" output by EntityDeveloper and set both ends of the association to false and the program/model behaved correctly (or at least the way I want it to).

Is the behavior of EntityDeveloper here intentional (i.e. that "inverse" can only be disabled at one end)? Or am I doing something fundamentally wrong here? If yes - Is there a best practice for such cases?

Thanks in advance

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Many to Many

Post by Shalex » Sat 28 Aug 2021 15:03

We could not find any samples of many-to-many with inverse=false on both ends in the official NHibernate documentation: https://nhibernate.info/doc/nhibernate- ... l-join-m2m.

muellermartin43
Posts: 4
Joined: Tue 01 Sep 2020 08:23

Re: Many to Many

Post by muellermartin43 » Mon 30 Aug 2021 06:01

Is there a reliable way to update the many-to-many collection from both sides?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Many to Many

Post by Shalex » Mon 30 Aug 2021 09:48

We will investigate the question and notify you about the result.

Post Reply