title: Sequelize create through association
body: <p>I'm working on a create method for an association between two classes.  The sequelize documentation indicates that this can be done in one step using includes</p>
  
  <pre><code>IntramuralAthlete.create(intramuralAthlete,{
           include: [Person]
      }).then((data,err)=&gt;{
           if(data)res.json(data);
           else res.status(422).json(err);
      }).catch(function(error) {
           res.status(422).json({message: "failed to create athlete", error: error.message});
  });
  </code></pre>
  
  <p>My model association looks like this </p>
  
  <pre><code>var Person = require('../models').person;
  var IntramuralAthlete = require('../models').intramuralAthlete;
  
  IntramuralAthlete.belongsTo(Person);
  </code></pre>
  
  <p>And the value of intramural athlete when I log it is </p>
  
  <pre><code>{ 
     person: 
     { firstName: 'Test',
       lastName: 'User',
       email: 'test@user.com'
    },
    grade: '12th',
    organizationId: 1 
  }
  </code></pre>
  
  <p>But I get the error <code>notNull Violation: personId cannot be null</code>.   This error makes it sound like something is wrong with the way I'm indicating to Sequelize that I'm intending to create the personId in that same call.  </p>
  
  <p>Is there something wrong in the way I indicate to the <code>create</code> statement what associated tables to create with the IntramuralAthlete?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:
  I have also tried with the following structure with the same result</p>
  
  <pre><code>{ 
    Person: { 
      firstName: 'Test',
      lastName: 'User',
      email: 'test@user.com'
   },
   grade: '12th',
   organizationId: 1 
  }
  </code></pre>
  
  <p>My model is as follows:</p>
  
  <pre><code>module.exports = function(sequelize, DataTypes) {
    return sequelize.define('intramuralAthlete', {
      id: {
        type: DataTypes.INTEGER(11),
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      createdAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: sequelize.literal('CURRENT_TIMESTAMP')
      },
      updatedAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: sequelize.literal('CURRENT_TIMESTAMP')
      },
      grade: {
        type: DataTypes.STRING,
        allowNull: true
      },
      age: {
        type: DataTypes.INTEGER(11),
        allowNull: true
      },
      school: {
        type: DataTypes.STRING,
        allowNull: true
      },
      notes: {
        type: DataTypes.STRING,
        allowNull: true
      },
      guardianId: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        references: {
          model: 'contact',
          key: 'id'
        }
      },
      personId: {
        type: DataTypes.INTEGER(11),
        allowNull: false,
        references: {
          model: 'person',
          key: 'id'
        }
      },
      mobileAthleteId: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        references: {
          model: 'mobileAthlete',
          key: 'id'
        }
      },
      organizationId: {
        type: DataTypes.INTEGER(11),
        allowNull: false,
        references: {
          model: 'organization',
          key: 'id'
        }
      }
    }, {
      tableName: 'intramuralAthlete'
    });
  };
  </code></pre>