Basically this error is saying that you have bad relation between the tables. Double check your table and the relation, and make sure its not related to autoincrement property. You can remove Auto Increment and generate ID or change the relationship.