You need to configure the mapping for the Id collection in the model.

In the case of a 1 to 1 relationship, everything is very clear. I do so

References(myEntity => myEntity.Prop).Column("my_entity_id").ReadOnly(); Map(myEntity => myEntity.PropId).Column("my_entity_id"); 

This means that in my essence MyEntity has a link to the Prop entity, and the PropId field is the identifier of this entity and it is through him that I change the related Prop entity to another one.

And how to make the same behavior for collections?

 HasMany(myEntity => myEntity.OtherProperties).KeyColumn("my_entity_id"); 

Indicates that the OtherProperty entity has a connection to MyEntity, but in order to specify which OtherProperty entities are associated with the current MyEntity (in the context of MyEntity) I would like to have the OtherPropertiesIdList property in it and work with it. But how to set up mapping?

  • ManyToMany need something? It is not done directly, you need to have an intermediate collection that will store this connection. - Monk
  • I need to have a collection of related entity identifiers in the model. It does not matter how many to many it is or has many. - iRumba am
  • In my opinion, you are doing something wrong. Why store Id separately is the first question. Second, where did you get the idea that Map and References do the same thing? github.com/FluentNHibernate/fluent-nhibernate/wiki/... map for properties, references for feedback from the collection. For your question - just make a collection of the type of your Id and use. - Monk
  • @Monk, I have never written that Map and Reference do the same thing. I want to make a collection of type Id, but how? That is, I need this collection to be filled with data when sampling and used when updating / adding data - iRumba
  • And double such mapping Prop at least works? Because I could not repeat it either - Id is in the database, but the link to the entity is not filled in on the download. - Monk

0