hi Tanguy,
Suppose there is an entity 'Teacher', and an entity 'Student' is of N:N relationship. The way Dynamics does is internally creating a internal entity, entity name could be checked in 'Customization->Entity->Teacher->N:N relationship', let say the entityname is 'Courses'.
This internal entity has associated teacherid, studentid, and its own 'Courses' entity record id.
Regarding your question on how to associate/disassociate, ideally, it should be use webAPI to create/delete record in this 'Courses' table.
The problem is that it seems webAPI is not able to CRUD on this internal entity, if that's the case, what we suggested is that you create an explicit entity 'Courses' table, with keys like 'CourseId', 'TeacherId','StudentId'. Then Teacher:Courses is 1:N, Student:Course is 1:N, and Teacher:Student is N:N.
Then if you need to associate/disassociat Teacher:Student relationship, it's just CRUD on this 'Course' entity.
Now it comes to another question, at a page Teacher, with related Courses subgrid, how do we associate a student. It should be, your subgrid dataset control, its manifest has two <data-set>s
<data-set> //bind to entity courses
<data-set> // bind to entity students
The 2nd <data-set> is used to retrieve all candidate students and let user to pick one. As you already have page TeacherId, you have StudentId when user picked, you should be able to use webAPI to create a new Course record.
Hopefully it makes sense to you
Anqi