Access denied while deleting an entity This is my Config entity:

 * @ConfigEntityType(
 *   id = "myentity",
 *   label = @Translation("My Entity"),
 *   controllers = {
 *     "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage",
 *     "list_builder" = "Drupal\mymodule\Controller\MyEntityListBuilder",
 *     "form" = {
 *       "default" = "Drupal\mymodule\Form\MyEntityForm",
 *       "delete" = "Drupal\mymodule\Form\MyEntityDeleteForm",
 *     },
 *   },
 *   admin_permission = "administer mymodule",
 *   config_prefix = "myentity",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "name",
 *     "url" = "url",
 *     "status" = "status"
 *   },
 *   links = {
 *     "canonical" = "mymodule.myentity_info",
 *     "add-form" = "mymodule.myentity_add",
 *     "edit-form" = "mymodule.myentity_edit",
 *     "delete-form" = "mymodule.myentity_delete",
 *   }
 * )
 */


The MyEntityDeleteForm:


/**
 * @file
 * Contains \Drupal\mymodule\Form\MyEntityDeleteForm.
 */

namespace Drupal\mymodule\Form;

use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Url;

/**
 * Defines a confirmation form for deletion of a custom menu.
 */
class MyEntityDeleteForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return t('Are you sure you want to delete the myentity %title?', array('%title' =&gt; $this-&gt;entity-&gt;label()));
  }

  /**
   * {@inheritdoc}
   */
  public function submit(array $form, array &amp;$form_state) {
    $this-&gt;entity-&gt;delete();
    drupal_set_message($this-&gt;t('The entity %title has been deleted.', array('%label' =&gt; $this-&gt;entity-&gt;label())));
    $form_state['redirect_route'] = $this-&gt;getCancelRoute();
  }

  public function getConfirmText() {
    return $this-&gt;t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelRoute() {
    return $this-&gt;entity-&gt;urlInfo('canonical');
  }
}


The route defined in routing.yml:

mymodule.myentity_delete:
  path: '/admin/config/search/mymodule/myentity/{myentity}/delete'
  defaults:
    _entity_form: 'mymodule_myentity.delete'
  requirements:
    _entity_access: 'mymodule_myentity'


I'm getting this error while trying to delete the entity:

Notice: Undefined offset: 1 in Drupal\Core\Entity\EntityAccessCheck-&gt;access() (line 46 of core/lib/Drupal/Core/Entity/EntityAccessCheck.php).
Drupal\Core\Entity\EntityAccessCheck-&gt;access(Object, Object, Object)
call_user_func_array(Array, Array)
Drupal\Core\Access\AccessManager-&gt;performCheck('access_check.entity', Object, Object, Object)
Drupal\Core\Access\AccessManager-&gt;checkAll(Array, Object, Object, Object)
Drupal\Core\Access\AccessManager-&gt;check(Object, Object, Object)
Drupal\Core\EventSubscriber\AccessSubscriber-&gt;onKernelRequestAccessCheck(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object)
Symfony\Component\EventDispatcher\EventDispatcher-&gt;doDispatch(Array, 'kernel.request', Object)
Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch('kernel.request', Object)
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch('kernel.request', Object)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1)
Drupal\Core\HttpKernel-&gt;handle(Object, 1, 1)
Drupal\Core\DrupalKernel-&gt;handle(Object)


And this message on the page:

Access denied
You are not authorized to access this page.
If you look at EntityAccessCheck::access() you'll see this:

$requirement = $route-&gt;getRequirement('_entity_access');
list($entity_type, $operation) = explode('.', $requirement);


The second line is causing the notice, and your access check to subsequently fail. Basically, the access method is expecting (requiring, in fact) your permission to contain an entity type and access operation, separated by a ..

If you take the node module's routing file as an example:

node.delete_confirm:
  path: '/node/{node}/delete'
  defaults:
    _entity_form: 'node.delete'
    _title: 'Delete'
  requirements:
    _entity_access: 'node.delete'
  options:
    _node_operation_route: TRUE


I would suggest you just need to change your route to match:

mymodule.myentity_delete:
  path: '/admin/config/search/mymodule/myentity/{myentity}/delete'
  defaults:
    _entity_form: 'mymodule_myentity.delete'
  requirements:
    _entity_access: 'mymodule_myentity.delete'