title: Node.js Sequelize ORM error with sourceKey on many-to-many relationship
body: <p>I have an error with <a href="https://www.npmjs.com/package/sequelize" rel="nofollow noreferrer">Sequelize</a> model.</p>
  <p>I have two models: <code>Hostel</code> and <code>Faculty</code>. And I need many-to-many relationship between them.</p>
  <p>I added to <code>Hostel</code> the next:</p>
  <pre><code>Hostel.belongsToMany(Faculty, {
    through: 'university.hostels_to_faculties',
    sourceKey: 'hostel_id',
    targetKey: 'faculty_id',
    onUpdate: 'CASCADE',
    onDelete: 'CASCADE'
  });
  </code></pre>
  <p>Full code source is here: <a href="https://github.com/ASUDR/backend/blob/dev/src/db/models/university/Hostel.ts#L41" rel="nofollow noreferrer">https://github.com/ASUDR/backend/blob/dev/src/db/models/university/Hostel.ts#L41</a></p>
  <p>And when I run this code, I get an error:</p>
  <blockquote>
  <p>/opt/app/node_modules/sequelize/lib/associations/belongs-to-many.js:129
  this.sourceKeyField = this.source.rawAttributes[this.sourceKey].field || this.sourceKey;</p>
  </blockquote>
  <p>(here is arrow that points out to field at this.source.rawAttributes[this.sourceKey].field)</p>
  <blockquote>
  <p>TypeError: Cannot read properties of undefined (reading 'field')
  at new BelongsToMany (/opt/app/node_modules/sequelize/lib/associations/belongs-to-many.js:129:69)
  at Function.belongsToMany (/opt/app/node_modules/sequelize/lib/associations/mixin.js:64:25)
  at file:///opt/app/dist/db/models/university/Hostel.js:24:8
  at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
  at async Loader.import (node:internal/modules/esm/loader:178:24)
  at async Object.loadESM (node:internal/process/esm_loader:68:5)
  at async handleMainPromise (node:internal/modules/run_main:63:12)</p>
  </blockquote>