This one had me stumped for a while so I thought it might be useful to share it with the class…

When you create a model in Magento that reads and writes data to a database table, by default, Magento expects the primary key of the table to be an auto_increment field named id.

If you want to use a primary key that is not an auto_increment field then you need to set the _isPkAutoIncrement flag on your model’s resource to false.

For example:

class MyCompany_MyModule_Model_Resource_Whatever extends Mage_Core_Model_Resource_Db_Abstract
    * constructor
    * @access public
    * @author Richard Meinertzhagen
    public function _construct()
        $this->_init('mycompany_mymodule/whatever', 'entity_id');

        // Primary key is not an auto_increment field
        $this->_isPkAutoIncrement = false;