'error: column "userId" does not exist Sequelize many-to-many relationsip

I try to create a many-to-many relation between users and templates in Postgres with Sequelize. But when I try to create a user I get the following error and can't find what the problem is.

  Executing (default): INSERT INTO "users" ("id","createdAt","updatedAt") VALUES (DEFAULT,$1,$2) RETURNING "id","userId","templateId","createdAt","updatedAt"
error: column "userId" does not exist

User Model

"use strict";
module.exports = (sequelize, DataTypes) => {
  const user = sequelize.define(
    "user",
    {
      name: DataTypes.STRING,
      email: DataTypes.STRING,
      phone: DataTypes.STRING,
      password: DataTypes.STRING
    },
    {}
  );
  user.associate = function(models) {
    user.belongsToMany(models.template, {through: 'User_Templates'})
  };
  return user;
};

Template model

"use strict";
module.exports = (sequelize, DataTypes) => {
  const template = sequelize.define(
    "template",
    {
      name: DataTypes.STRING,
      html: DataTypes.STRING
    },
    {}
  );
  template.associate = function(models) {
    template.belongsToMany(models.user, {through: 'User_Templates'})
  };
  return template;
};

User_Template model (junction table)

"use strict";
module.exports = (sequelize, DataTypes) => {
  const User_Template = sequelize.define(
    "user",
    {
      userId: DataTypes.INTEGER,
      templateId: DataTypes.INTEGER
    },
    {}
  );
  User_Template.associate = function(models) {
    User_Template.belongsTo(models.user, {
      foreignKey: 'userId',
      as: 'user'
    })
    User_Template.belongsTo(models.template, {
      foreignKey: 'templateId',
      as: 'template'
    })
  };
  return User_Template;
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source