Perhaps I am not mapping it quite right either side of the relationship.
>From the player:
HasManyToMany(x => x.VehicleRegistrations)
.Cascade.AllDeleteOrphan()
.Table(JoinNames([TableNames.efcore, TableNames.wbe,
nameof(VehicleRegistration).ToLower()]));
>From the vehicle:
HasManyToMany(x => x.VehicleRegistrations)
.Cascade.AllDeleteOrphan()
.Inverse()
.Table(JoinNames([TableNames.efcore, TableNames.wbe,
nameof(VehicleRegistration).ToLower()]));
Whereas this somewhat dated example:
https://belter.io/manytomany-fluentnhibernate not mentioning any joining
object whatsoever, which is a bit interesting to me.
Question though, in my joining table, what happens if I want to identify
additional bits in that part of the model? i.e. is not just "joining two
tables, with two FK references" and so forth.
If I go by the example, it appears to me the map drills right through that
would-be entity.
Anyone?
Thanks...
On Wednesday, October 22, 2025 at 6:14:40 PM UTC-4 Michael W Powell wrote:
> Also it's not the only columns which are misidentified, or that I have not
> trained the ORM how to identify, YET... Which is what I'd like to puzzle
> through if it is even possible, vehiclereg0_.Player_id.
>
> Honestly I'm not even sure how this SQL is being formed, unless perhaps I
> have a relationship or reference inversion incorrect perhaps.
>
> SELECT vehiclereg0_.Player_id as player4_5_9_,
> vehiclereg0_.VehicleRegistration_id as vehicleregistration5_5_9_,
> vehiclereg1_.Id as id1_5_0_, vehiclereg1_.PlayerId as playerid2_5_0_,
> vehiclereg1_.VehicleId as vehicleid3_5_0_, player2_.Id as id1_4_1_,
> player2_.ServerProfileId as serverprofileid2_4_1_ ... left outer join
> public.efcore_wbe_serverprofile serverprof9_ on
> motorvehic6_.ServerProfileId=serverprof9_.Id WHERE vehiclereg0_.Player_id=?
>
> The example SQL above, not even sure how the majority of all this is even
> necessary, seems like extraneous junk happening somehow, because I am
> mapping a joining table? Is there a better base mapping class for that,
> perhaps? I'm not sure...
>
> On Wednesday, October 22, 2025 at 6:08:40 PM UTC-4 Michael W Powell wrote:
>
>> Getting some errors after mapping the joining table. It is for whatever
>> reason looking for a column i.e. vehiclereg0_.vehicleregistration_id, vreg
>> being object 'table'. The base model Id property should be this:
>>
>> Id(x => x.Id)
>> .Column(nameof(ModelBase.Id))
>> .Not.Nullable()
>> .GeneratedBy.GuidComb();
>>
>> Not sure why the joining is trying to label it "vehicleregistration_id"
>> that is definitely incorrect.
>>
>> How to persuade NH? Fluent NH? How to map it correctly?
>>
>> The only columns that should really be mapped otherwise are:
>>
>> References(x => x.Owner)
>> .Not.Nullable();
>>
>> References(x => x.Vehicle)
>> .Not.Nullable();
>>
>> TBD what level of inverse relationship there should be.
>>
>> Note, vehicle can only be registered to one player at a time, so perhaps
>> M2M is overkill.
>>
>> Thoughts?
>>
>> Thank you...
>>
>> On Wednesday, October 1, 2025 at 6:02:14 PM UTC-4 Michael W Powell wrote:
>>
>>> Hello,
>>>
>>> I want to map a joining table between A and B. I have a sense how to map
>>> the A and B sides of the relationship, one of which I think should be
>>> .Inverse(), yes?
>>>
>>> I am not hundred percent positive, but I may need to attach additional
>>> properties than just linking A to B and vice versa.
>>>
>>> So I need to introduce a map for the joining table C as well. But,
>>> personally, I'm not quite sure how that would work.
>>>
>>> Any insights?
>>>
>>> Best, thank you...
>>>
>>> Michael W. Powell
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/fluent-nhibernate/f3bf1d0c-a951-42c6-9365-77a7ca56d8ban%40googlegroups.com.