{"action":"opened","issue":{"url":"https://api.github.com/repos/yii2tech/ar-variation/issues/3","labels_url":"https://api.github.com/repos/yii2tech/ar-variation/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/yii2tech/ar-variation/issues/3/comments","events_url":"https://api.github.com/repos/yii2tech/ar-variation/issues/3/events","html_url":"https://github.com/yii2tech/ar-variation/issues/3","id":118558408,"number":3,"title":"Primary key issue","user":{"login":"turalsprofile","id":724507,"avatar_url":"https://avatars.githubusercontent.com/u/724507?v=3","gravatar_id":"","url":"https://api.github.com/users/turalsprofile","html_url":"https://github.com/turalsprofile","followers_url":"https://api.github.com/users/turalsprofile/followers","following_url":"https://api.github.com/users/turalsprofile/following{/other_user}","gists_url":"https://api.github.com/users/turalsprofile/gists{/gist_id}","starred_url":"https://api.github.com/users/turalsprofile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turalsprofile/subscriptions","organizations_url":"https://api.github.com/users/turalsprofile/orgs","repos_url":"https://api.github.com/users/turalsprofile/repos","events_url":"https://api.github.com/users/turalsprofile/events{/privacy}","received_events_url":"https://api.github.com/users/turalsprofile/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-24T08:39:51Z","updated_at":"2015-11-24T08:39:51Z","closed_at":null,"body":"Let's say we have structure below. As far as I know, behaviour first creates all `ItemTranslation` rows without `itemId` field, then inserts into `item` itself then updates `ItemTranslation` with id from `item` table.\r\n\r\nI did `itemId`, `languageId` primary key as you did. But during `model->save()` error occured: `itemId cannot be empty`.\r\n\r\nI removed primary key from those two fields, everything went okay. \r\n\r\nWhat am I doing wrong?\r\n\r\n```\r\nCREATE TABLE `Item`\r\n(\r\n   `id` integer NOT NULL AUTO_INCREMENT,\r\n   `name` varchar(64) NOT NULL,\r\n   `price` integer,\r\n    PRIMARY KEY (`id`)\r\n) ENGINE InnoDB;\r\n\r\nCREATE TABLE `ItemTranslation`\r\n(\r\n   `itemId` integer NOT NULL,\r\n   `languageId` varchar(5) NOT NULL,\r\n   `title` varchar(64) NOT NULL,\r\n   `description` TEXT,\r\n    PRIMARY KEY (`itemId`, `languageId`)\r\n    FOREIGN KEY (`itemId`) REFERENCES `Item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\r\n    FOREIGN KEY (`languageId`) REFERENCES `Language` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\r\n) ENGINE InnoDB;\r\n```"}}