Create dynamic block instances In Drupal 7, if we need to define multiple instances of blocks from a database table, we use a foreach loop to return the array key, and then we we get all the multiple instances of our block using hook_block_info().

function mymodule_block_info() {
    $blocks = array();
    $add = db_select('mymodule_blocks_data', 'n')
                  -&gt;fields('n', array('delta', 'title', 'content_type'))
                  -&gt;condition('n.form_type', 'Add', '=')
                  -&gt;execute();
    foreach ($add as $row) {
        $blocks[$row-&gt;delta] = array(
      'info' =&gt; t('@name (Add Form Block) Type: @type', array('@name' =&gt; $row-&gt;title, '@type' =&gt; $row-&gt;content_type)),
      'cache' =&gt; DRUPAL_NO_CACHE,
        );
    }

    $edit = db_select('mymodule_blocks_data', 'n')
                  -&gt;fields('n', array('delta', 'title', 'content_type', 'nid'))
                  -&gt;condition('n.form_type', 'Edit', '=')
                  -&gt;execute();
    foreach ($edit as $row) {
        $blocks[$row-&gt;delta] = array(
      'info' =&gt; t('@name (Edit Form Block) Nid: @nid', array('@name' =&gt; $row-&gt;title, '@nid' =&gt; $row-&gt;nid)),
      'cache' =&gt; DRUPAL_NO_CACHE,
        );
    }

    return $blocks;
}


In Drupal 8, I suppose hook_block_info() is replaced by plugin derivatives.
Though I found a way here where they display nodes by using the entity manager, I have still to understand what I need to do when I am using my custom database table, and not an entity.

What is the equivalent code in Drupal 8 for hook_block_info()?
Create a file ex : YourBlock.php in   Drupal\mymodule\Plugin\Derivative\YourBlock.php  

&lt;?php

namespace Drupal\mymodule\Plugin\Derivative;

use Drupal\Component\Plugin\Derivative\DeriverBase;

class YourBlock extends DeriverBase
{
    public function getDerivativeDefinitions($base_plugin_definition)
    {
        $results = \Drupal::database()-&gt;select('mymodule_blocks_data', 'n')
                  -&gt;fields('n', array('delta','title', 'content_type'))
                  -&gt;condition('n.form_type', 'Add', '=')
                  -&gt;execute();
        foreach ($results as $result) {
            $this-&gt;derivatives[$result-&gt;delta] = $base_plugin_definition;
            $this-&gt;derivatives[$result-&gt;delta]['admin_label'] = t('Title: @name content type: @ctype ', array('@name' =&gt; $result-&gt;title, '@ctype' =&gt; $result-&gt;content_type));
        }

        return $this-&gt;derivatives;
    }
}



  Also add the necessary annotation to display all the dynamic block instances in 

Drupal\mymodule\Plugin\Block\YourBlock.php



&lt;?php

namespace Drupal\mymodule\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Display all instances for 'YourBlock' block plugin.
 *
 * @Block(
 *   id = "mymodule_block",
 *   admin_label = @Translation("Your block"),
 *   deriver = "Drupal\mymodule\Plugin\Derivative\YourBlock"
 * )
 */


Rebuild the cache as well