Why can’t I set auto increment to a field that is used as a foreign key in another table?

I want both id’s to auto increment: tables

I get this error when synchronizing the model:

Executing SQL script in server
ERROR: Error 3780: Referencing column 'taskList_id' and referenced column 'id' in foreign key constraint 'fk_task_taskList' are incompatible.
SQL Code:
        ALTER TABLE `easyManage`.`task` 
        ADD CONSTRAINT `fk_task_taskList`
          FOREIGN KEY (`taskList_id`)
          REFERENCES `easyManage`.`taskList` (`id`)
          ON DELETE CASCADE
          ON UPDATE NO ACTION

Answer

tasklist_id in table task is varchar(55). It has to be int to hold id from table tasklist

Leave a Reply

Your email address will not be published. Required fields are marked *