protected function getKeyNameFromResource()
    {
        $resource = $this->getForeignResource();

        if (!is_null($resource) && (($field = $resource->getPrimaryField()) != null)) {
            return $field->name;
        }

        return null;
    }