private function _getPrimaryKeyName(\yii\db\ActiveRecord $model, $composite = false)
    {
        $primaryKey = $model->primaryKey();

        if (!$composite && count($primaryKey) > 1) {
            throw new Exception('Model has composit key which is not allowed. Relations cannot be established');
        }

        return array_shift($primaryKey);
    }