Error with model validation Hi I'm getting this error when I try to validate a model.

Craft\mymodelModel and its behaviors do not have a method or closure named "getTableSchema".

I'm using the following code in the controller function that calls the save. It saves the data fine but I want to validate the model first before it does so but this is throwing the above error. What am I missing?

$model-&gt;setAttributes($attribute);

if($model-&gt;validate()) {
    // code that sends model off to be saved
} else {
    $model-&gt;getErrors();    
}


Cheers

Model class code:

namespace Craft;

    /**
    * myModel Model
    *
    * Provides a read-only object representing a myModel, which is   returned
    * by our service class and can be used in our templates and controllers.
    */
    class myModels_myModelModel extends BaseModel
   {
    /**
     * Defines what is returned when someone puts {{ myModel }} directly
     * in their template.
     *
     * @return string
     */
     public function __toString()
   {
       return $this-&gt;name;
   }

   /**
     * Define the attributes this model will have.
     *
     * @return array
     */
     public function defineAttributes()
     {
        return array(
            'id'    =&gt; array(AttributeType::Number, 'required' =&gt; true, 'unique' =&gt; true),
        'field1'    =&gt; array(AttributeType::Number, 'required' =&gt; true),
        'field2' =&gt; array(AttributeType::Enum, 'values' =&gt; "value1,value2"),
        'field3'  =&gt; array(AttributeType::Enum, 'values' =&gt; "value1,value2,value3", 'required' =&gt; true, 'default' =&gt; 'value1'),
        'field4' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field5' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field6' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field7' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field8' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field9' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field10' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field11' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field12' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
        'field13' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false)
        );
    }

    /**
     * Get User
     */
    public function getmyModel()
    {
        if ($this-&gt;userId)
        {
            return craft()-&gt;users-&gt;getUserById($this-&gt;userId);
        }
    }

}
I just had a bit more of a look into this, I got the same error as you but by changing

'id' =&gt; array(AttributeType::Number, 'required' =&gt; true, 'unique' =&gt; true),


to just

id =&gt; AttributeType::Number


It fixed the issue and I was able to validate on it no problem, I don't think you need to worry about the ID being unique or being set on the model as this will be handled automatically by your record when you use it to save to the database, so you can be certain that every models id will always be unique.