title: Unhandled rejection SequelizeEagerLoadingError: is not associated to, and Cannot read property 'getTableName' of undefined
body: <p>I have 3 tables: User, Trip, authoriseDate.
  here is associate:
  A user has many trips and a user has one authoriseDate
  User one to many Trips
  User one to one authoriseDate
  and here is the models
  User</p>
  
  <pre><code> module.exports = (sequelize, DataTypes) =&gt; {
    const user = sequelize.define('User', {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      email: { type: DataTypes.STRING(50), unique: true },
      phoneNumber: {
        type: DataTypes.STRING(12), unique: true,
      },
    }, {
      classMethods: {
        associate(models) {
          // associations can be defined here
          user.hasOne(models.authoriseDate, { foreignKey: 'userId' });
          user.hasMany(models.Trip, { foreignKey: 'userId' });
        },
      },
    });
    return user;
  };
  </code></pre>
  
  <p>Trip</p>
  
  <pre><code>module.exports = (sequelize, DataTypes) =&gt; {
    const trip = sequelize.define('Trip', {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      userId: DataTypes.INTEGER,
      status: DataTypes.INTEGER,
    }, {
      classMethods: {
        associate(models) {
          // associations can be defined here
          trip.belongsTo(models.User, { foreignKey: 'userId' });
        },
      },
    });
    return trip;
  };
  </code></pre>
  
  <p>authoriseDate</p>
  
  <pre><code>module.exports = (sequelize, DataTypes) =&gt; {
    const authoriseDate = sequelize.define('AuthoriseDate', {
      id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
      userId: DataTypes.INTEGER,
      lastAuthorise: DataTypes.DATE,
    }, {
      classMethods: {
        associate(models) {
          // associations can be defined here
          authoriseDate.belongsTo(models.User, { foreignKey: 'userId', });
        },
      },
    });
    return authoriseDate;
  };
  </code></pre>
  
  <p>but when I using findAll function </p>
  
  <pre><code>models.User.findAll({
      include: [{
        model: models.Trip,
      },
      {
        model: models.authoriseDate,
      }],
    })
  </code></pre>
  
  <p>here is my model file</p>
  
  <pre><code>    'use strict';
  
  var fs = require('fs');
  var path = require('path');
  var Sequelize = require('sequelize');
  var basename = path.basename(module.filename);
  //var env = process.env.NODE_ENV || 'development';
  //var config    = require(__dirname + './../../../config/config.json')[env];
  var config = require('../../config/env')
  var db = {};
  
  // if (config.use_env_variable) {
  //   var sequelize = new Sequelize(process.env[config.use_env_variable]);
  // } else {
  //   var sequelize = new Sequelize(config.database, config.username, config.password, config);
  // }
  
  var sequelize = new Sequelize(config.dbName, config.dbUserName, config.dbPassword, {
    host: config.dbHost,
    dialect: config.dbDialect,
  });
  
  fs
    .readdirSync(__dirname)
    .filter(function (file) {
      return (file.indexOf('.') !== 0) &amp;&amp; (file !== basename);
    })
    .forEach(function (file) {
      if (file.slice(-3) !== '.js') return;
      var model = sequelize['import'](path.join(__dirname, file));
      db[model.name] = model;
    });
  
  Object.keys(db).forEach(function (modelName) {
    if (db[modelName].associate) {
      db[modelName].associate(db);
    }
  });
  
  db.sequelize = sequelize;
  db.Sequelize = Sequelize;
  
  module.exports = db;
  </code></pre>
  
  <p>I am getting the errors:
  <strong>Unhandled rejection SequelizeEagerLoadingError: Trip is not associated to User, and Cannot read property 'getTableName' of undefined</strong>
  I don't know how to solve these errors, anyone help me please</p>