diff --git a/core/includes/module.inc b/core/includes/module.inc
index f6d47b6..2fdf63c 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -491,11 +491,13 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
 
   $modules_installed = array();
   $modules_enabled = array();
-  $schema_store = drupal_container()->get('keyvalue')->get('system.schema');
-  $module_config = config('system.module');
-  $disabled_config = config('system.module.disabled');
-  $module_filenames = drupal_container()->getParameter('container.modules');
   foreach ($module_list as $module) {
+    // Each iteration through this loop, there's potentially a new
+    // drupal_container() so refetch these objects.
+    $module_config = config('system.module');
+    $disabled_config = config('system.module.disabled');
+    $module_filenames = drupal_container()->getParameter('container.modules');
+
     // Only process modules that are not already enabled.
     $enabled = $module_config->get("enabled.$module") !== NULL;
     if (!$enabled) {
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index b472b8f..f8b4c45 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -424,7 +424,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
    * Implements Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename().
    */
   public function getQueryServicename() {
-    throw new \LogicException('Querying configuration entities is not supported.');
+    return 'entity.query.config';
   }
 
   /**
diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php
index 2076707..30708c8 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -52,8 +52,7 @@ public function build(ContainerBuilder $container) {
 
     $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
       ->addArgument(new Reference('config.storage'))
-      ->addArgument(new Reference('event_dispatcher'))
-      ->addTag('persist');
+      ->addArgument(new Reference('event_dispatcher'));
 
     // Register staging configuration storage.
     $container
diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
index 18d92d8..6870d67 100644
--- a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
+++ b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
@@ -36,6 +36,14 @@ function setUp() {
   }
 
   /**
+   * Overrides \Drupal\simpletest\DrupalUnitTestBase::containerBuild().
+   */
+  public function containerBuild($container) {
+    parent::containerBuild($container);
+    $container->removeDefinition('entity.query.denormalize');
+  }
+
+  /**
    * Creates a field and an instance of it.
    *
    * @param string $field_name
diff --git a/core/modules/entity/entity.install b/core/modules/entity/entity.install
index 2e1efd7..ae0ae63 100644
--- a/core/modules/entity/entity.install
+++ b/core/modules/entity/entity.install
@@ -8,6 +8,93 @@
 use Drupal\Component\Uuid\Uuid;
 
 /**
+ * Implements hook_schema().
+ */
+function entity_schema() {
+  $schema['config_entity_denormalized'] = array(
+    'description' => 'This table is storing denormalized configuration entity objects for query purposes.',
+    'fields' => array(
+      'entity_type' => array(
+        'description' => 'Tne type of the config entity.',
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'entity_id' => array(
+        'description' => 'Tne ID of the config entity.',
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'name' => array(
+        'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
+        'type' => 'varchar',
+        'length' => 237,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'value' => array(
+        'description' => 'The value.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+    ),
+    'primary key' => array('entity_type', 'entity_id', 'name'),
+    'index' => array(
+      'query_name' => array('entity_type', 'name', array('value', 64)),
+      'query_value' => array('entity_type', array('value', 64), 'name'),
+    ),
+  );
+  return $schema;
+}
+
+function entity_schema_0() {
+  $schema['config_entity_denormalized'] = array(
+    'description' => 'This table is storing denormalized configuration entity objects for query purposes.',
+    'fields' => array(
+      'entity_type' => array(
+        'description' => 'Tne type of the config entity.',
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'entity_id' => array(
+        'description' => 'Tne ID of the config entity.',
+        'type' => 'varchar',
+        'length' => 64,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'name' => array(
+        'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
+        'type' => 'varchar',
+        'length' => 237,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'value' => array(
+        'description' => 'The value.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+    ),
+    'primary key' => array('entity_type', 'entity_id', 'name'),
+    'index' => array(
+      'query_name' => array('entity_type', 'name', array('value', 64)),
+      'query_value' => array('entity_type', array('value', 64), 'name'),
+    ),
+  );
+  return $schema;
+}
+
+/**
  * Returns the raw configuration object for an EntityDisplay entity.
  *
  * The function returns the existing configuration entry if it exists, or
diff --git a/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php
new file mode 100644
index 0000000..84f6cad
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Condition.php
@@ -0,0 +1,120 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\ConfigQuery\Condition.
+ */
+
+namespace Drupal\entity\ConfigQuery;
+
+use Drupal\Core\Entity\Query\ConditionBase;
+use Drupal\Core\Entity\Query\ConditionInterface;
+use Drupal\Core\Database\Query\SelectInterface;
+use Drupal\Core\Database\Query\Condition as SqlCondition;
+
+class Condition extends ConditionBase {
+
+  /**
+   * Implements \Drupal\Core\Entity\Query\ConditionInterface::compile().
+   */
+  public function compile($conditionContainer) {
+    // If this is not the top level condition group then the sql query is
+    // added to the $conditionContainer object by this function itself. The
+    // SQL query object is only necessary to pass to Query::addField() so it
+    // can join tables as necessary. On the other hand, conditions need to be
+    // added to the $conditionContainer object to keep grouping.
+    if ($conditionContainer instanceof SelectInterface) {
+      $top_group = TRUE;
+      $alias = 'base_table';
+      $sqlQuery = $conditionContainer;
+    }
+    else {
+      $top_group  = FALSE;
+      $sqlQuery = $conditionContainer->sqlQuery;
+    }
+
+    // Iterate over all conditions and act based on whether they are a condition
+    // group or a single condition.
+    foreach ($this->conditions as $key => $condition) {
+      // If it's a condition group, compile the condition group and add it to
+      // the sql.
+      if ($condition['field'] instanceOf ConditionInterface) {
+        $sqlCondition = new SqlCondition($condition['field']->getConjunction());
+        // Add the SQL query to the object before calling this method again.
+        $sqlCondition->sqlQuery = $sqlQuery;
+        $condition['field']->compile($sqlCondition);
+        $sqlQuery->condition($sqlCondition);
+      }
+      // If it's a simple condition apply the query logic.
+      else {
+        $and = strtoupper($this->conjunction) == 'AND';
+        $or = !$and;
+        if (($and && (!$top_group || $key)) || ($or && !$top_group && !$key)) {
+          $alias = $sqlQuery->join('config_entity_denormalized', NULL, '%alias.entity_type = base_table.entity_type AND %alias.entity_id = base_table.entity_id');
+        }
+        if ($and) {
+          $container = $conditionContainer;
+        }
+        else {
+          $container = new SqlCondition('AND');
+        }
+        $this->translateCondition($condition);
+        $container->condition("$alias.name", $condition['field'], $condition['field_operator']);
+        $container->condition("$alias.value", $condition['value'], $condition['operator']);
+        if ($or) {
+          $conditionContainer->condition($container);
+        }
+      }
+    }
+  }
+
+  /**
+   * Implements \Drupal\Core\Entity\Query\ConditionInterface::exists().
+   */
+  public function exists($field, $langcode = NULL) {
+    return $this->condition($field, NULL, 'IS NOT NULL', $langcode);
+  }
+
+  /**
+   * Implements \Drupal\Core\Entity\Query\ConditionInterface::notExists().
+   */
+  public function notExists($field, $langcode = NULL) {
+    return $this->condition($field, NULL, 'IS NULL', $langcode);
+  }
+
+  /**
+   * Translates a condition array to it's sql equivalents.
+   *
+   * @param array $condition
+   *   An associative array containing the follow keys:
+   *     - field: The entity property to filter on.
+   *     - operator: The operator used in the condition, for example "=".
+   *     - value: The actual value to filter by.
+   */
+  protected function translateCondition(array &$condition) {
+    if (strpos($condition['field'], '*') === FALSE) {
+      $condition['field_operator'] = '=';
+    }
+    else {
+      $condition['field_operator'] = 'LIKE';
+      $condition['field'] = str_replace('*', '%', $condition['field']);
+    }
+    switch ($condition['operator']) {
+      case 'STARTS_WITH':
+        $condition['value'] .= '%';
+        $condition['operator'] = 'LIKE';
+        break;
+
+      case 'CONTAINS':
+        $condition['value'] = '%' . $condition['value'] . '%';
+        $condition['operator'] = 'LIKE';
+        break;
+
+      case 'ENDS_WITH':
+        $condition['value'] = '%' . $condition['value'];
+        $condition['operator'] = 'LIKE';
+        break;
+
+    }
+  }
+}
diff --git a/core/modules/entity/lib/Drupal/entity/ConfigQuery/Denormalize.php b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Denormalize.php
new file mode 100644
index 0000000..0b49b95
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Denormalize.php
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\ConfigQuery\Denormalize.
+ */
+
+namespace Drupal\entity\ConfigQuery;
+
+use Drupal\Core\Config\ConfigEvent;
+use Drupal\Core\Database\Connection;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * Defines a event subscriber that denormalizes the configuration entity values.
+ */
+class Denormalize implements EventSubscriberInterface {
+
+  /**
+   * @var \Drupal\Core\Database\Connection
+   *   The database connection containing the denormalization table.
+   */
+  protected $connection;
+
+  /**
+   * The entity type.
+   *
+   * @var string
+   */
+  protected $entityType;
+
+  /**
+   * The ID of the entity.
+   */
+  protected $entityID;
+
+  /**
+   * The config object to react on.
+   *
+   * @var \Drupal\Core\Config\Config
+   */
+  protected $config;
+
+  /**
+   * A database insert object to put the config values into the table.
+   *
+   * @var \Drupal\Core\Database\Query\Insert
+   */
+  public $insert;
+
+  public function __construct(Connection $connection) {
+    $this->connection = $connection;
+  }
+
+  /**
+   * Reacts on the config.save event to denormalize the entity values.
+   *
+   * @param \Drupal\Core\Config\ConfigEvent $event
+   *   The config event object containing the config object being written.
+   */
+  public function configSave(ConfigEvent $event) {
+    $transaction = $this->connection->startTransaction();
+    $this->configDelete($event);
+    if ($this->entityType) {
+      $this->insert = $this->connection->insert('config_entity_denormalized')
+        ->fields(array('entity_type', 'entity_id', 'name', 'value'));
+      $this->values($this->config->get());
+      $this->insert->execute();
+    }
+  }
+
+  /**
+   * Reacts on the config.delete event to remove the entity values.
+   *
+   * @param \Drupal\Core\Config\ConfigEvent $event
+   *   The config event object containing the config object being written.
+   */
+  public function configDelete(ConfigEvent $event) {
+    $this->config = $event->getConfig();
+    $name = $this->config->getName();
+    if ($this->entityType = config_get_entity_type_by_name($name)) {
+      $entity_info = entity_get_info($this->entityType);
+      $this->entityID = substr($name, strlen($entity_info['config_prefix']) + 1);
+      $this->connection->delete('config_entity_denormalized')
+        ->condition('entity_type', $this->entityType)
+        ->condition('entity_id', $this->entityID)
+        ->execute();
+    }
+  }
+
+  /**
+   * Set all entity values to the database insert object.
+   *
+   * @param array $data
+   *   The contents of the config object.
+   * @param string $prefix
+   *   The current config prefix.
+   */
+  protected function values($data, $prefix = '') {
+    foreach ($data as $key => $value) {
+      if (is_array($value)) {
+        $this->values($value, "$prefix$key.");
+      }
+      else {
+        $this->insert->values(array($this->entityType, $this->entityID, "$prefix$key", $value));
+      }
+    }
+  }
+
+  /**
+   * Implements \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents().
+   *
+   * @return array
+   *   Returns the subscribed events.
+   */
+  public static function getSubscribedEvents() {
+    $events['config.save'][] = array('configSave', 20);
+    $events['config.delete'][] = array('configDelete', 20);
+    return $events;
+  }
+}
diff --git a/core/modules/entity/lib/Drupal/entity/ConfigQuery/Query.php b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Query.php
new file mode 100644
index 0000000..0904e61
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/ConfigQuery/Query.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\ConfigQuery\Query.
+ */
+
+namespace Drupal\entity\ConfigQuery;
+
+use Drupal\Core\Entity\Query\QueryBase;
+
+/**
+ * Defines the entity query for configuration entities.
+ */
+class Query extends QueryBase {
+
+  /**
+   * @var \Drupal\Core\Database\Connection $connection
+   *   The Connection object containing the normalized configuration entity values.
+   */
+  protected $connection;
+
+  /**
+   * Constructs a Query object.
+   *
+   * @param string $entity_type
+   *   The entity type.
+   * @param string $conjunction
+   *   - AND: all of the conditions on the query need to match.
+   *   - OR: at least one of the conditions on the query need to match.
+   * @param \Drupal\Core\Database\Connection $connection
+   *   The database connection to run the query against.
+   */
+  public function __construct($entity_type, $conjunction, $connection) {
+    parent::__construct($entity_type, $conjunction);
+    $this->connection = $connection;
+  }
+
+  /**
+   * Implements \Drupal\Core\Entity\Query\QueryInterface::conditionGroupFactory().
+   */
+  public function conditionGroupFactory($conjunction = 'AND') {
+    return new Condition($conjunction);
+  }
+
+  /**
+   * Implements \Drupal\Core\Entity\Query\QueryInterface::execute().
+   */
+  public function execute() {
+    $sqlQuery = $this->connection->select('config_entity_denormalized', 'base_table', array('conjunction' => $this->conjunction));
+    $sqlQuery->addField('base_table', 'entity_id');
+
+    // Add all kind of tags to the query.
+    $sqlQuery->addTag('entity_query');
+    $sqlQuery->addTag('entity_query_' . $this->entityType);
+
+    // Add further tags added.
+    if (isset($this->alterTags)) {
+      foreach ($this->alterTags as $tag => $value) {
+        $sqlQuery->addTag($tag);
+      }
+    }
+
+    // Add further metadata added.
+    if (isset($this->alterMetaData)) {
+      foreach ($this->alterMetaData as $key => $value) {
+        $sqlQuery->addMetaData($key, $value);
+      }
+    }
+
+    $this->condition->compile($sqlQuery);
+
+    // Let the pager do it's work.
+    $this->initializePager();
+    if ($this->range) {
+      $sqlQuery->groupBy('entity_id');
+      $sqlQuery->range($this->range['start'], $this->range['length']);
+    }
+    if ($this->count) {
+      $sqlQuery->groupBy('entity_id');
+      return $sqlQuery->countQuery()->execute()->fetchField();
+    }
+
+    return drupal_map_assoc($sqlQuery->execute()->fetchCol());
+  }
+}
diff --git a/core/modules/entity/lib/Drupal/entity/ConfigQuery/QueryFactory.php b/core/modules/entity/lib/Drupal/entity/ConfigQuery/QueryFactory.php
new file mode 100644
index 0000000..5fcd711
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/ConfigQuery/QueryFactory.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\ConfigQuery\QueryFactory.
+ */
+
+namespace Drupal\entity\ConfigQuery;
+
+/**
+ * Factory class creating entity query objects for the config backend.
+ */
+class QueryFactory {
+
+  /**
+   * @var \Drupal\Core\Database\Connection $connection
+   *   The Connection object containing the normalized configuration entity values.
+   */
+  protected $connection;
+
+  /**
+   * Constructs a QueryFactory object.
+   *
+   * @param \Drupal\Core\Database\Connection $connection
+   *   The Connection object with the normalized configuration entity values.
+   */
+  function __construct($connection) {
+    $this->connection = $connection;
+  }
+
+  /**
+   * Instantiate a entity query for a certain entity type.
+   *
+   * @param string $entity_type
+   *   The entity type for the query.
+   * @param string $conjunction
+   *   The operator to use to combine conditions: 'AND' or 'OR'.
+   *
+   * @return \Drupal\entity\ConfigQuery\Query
+   *   A entity query for a specific configuration entity type.
+   */
+  function get($entity_type, $conjunction = 'AND') {
+    return new Query($entity_type, $conjunction, $this->connection);
+  }
+}
diff --git a/core/modules/entity/lib/Drupal/entity/EntityBundle.php b/core/modules/entity/lib/Drupal/entity/EntityBundle.php
new file mode 100644
index 0000000..303055f
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/EntityBundle.php
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\EntityBundle.
+ */
+
+namespace Drupal\entity;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+
+/**
+ * Bundle class for entity services.
+ */
+class EntityBundle extends Bundle {
+
+  /**
+   * Implements \Symfony\Component\HttpKernel\Bundle\BundleInterface::build().
+   */
+  public function build(ContainerBuilder $container) {
+    $container->register('entity.query.config', 'Drupal\entity\ConfigQuery\QueryFactory')
+      ->addArgument(new Reference('database'));
+    $container->register('entity.query.denormalize', 'Drupal\entity\ConfigQuery\Denormalize')
+      ->addArgument(new Reference('database'))
+      ->addTag('event_subscriber');
+  }
+
+}
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php b/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php
new file mode 100644
index 0000000..8aa5492
--- /dev/null
+++ b/core/modules/entity/lib/Drupal/entity/Tests/ConfigEntityQueryTest.php
@@ -0,0 +1,249 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\entity\Tests\ConfigEntityQueryTest.
+ */
+
+namespace Drupal\entity\Tests;
+
+use Drupal\simpletest\DrupalUnitTestBase;
+use Drupal\entity\Query\QueryFactory;
+
+/**
+ * Tests the config entity query.
+ *
+ * @see \Drupal\Core\entity\Query
+ */
+class ConfigEntityQueryTest extends DrupalUnitTestBase {
+
+  static $modules = array('config_test');
+
+  /**
+   * Stores the search results for alter comparision.
+   *
+   * @var array
+   */
+  protected $queryResults;
+
+  /**
+   * The query factory used to construct all queries in the test.
+   *
+   * @var \Drupal\Core\Entity\Query\QueryFactory
+   */
+  protected $factory;
+
+  /**
+   * Stores all config entities created for that test.
+   *
+   * @var array
+   */
+  protected $entities;
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Config Entity Query',
+      'description' => 'Tests Config Entity Query functionality.',
+      'group' => 'Configuration',
+    );
+  }
+
+  protected function setUp() {
+    parent::setUp();
+    $this->enableModules(array('entity'), TRUE);
+    $this->factory = $this->container->get('entity.query');
+
+    $this->entities = array();
+    $entity = entity_create('config_test', array(
+        'label' => $this->randomName(),
+        'id' => 1,
+      )
+    );
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+
+    $entity = entity_create('config_test', array(
+        'label' => $this->randomName(),
+        'id' => 2,
+      )
+    );
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+
+    $entity = entity_create('config_test', array(
+        'label' => 'test_prefix_' . $this->randomName(),
+        'id' => 3,
+      )
+    );
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+
+    $entity = entity_create('config_test', array(
+        'label' => $this->randomName() . '_test_suffix',
+        'id' => 4,
+      )
+    );
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+
+    $entity = entity_create('config_test', array(
+        'label' => $this->randomName() . '_test_contains_' . $this->randomName(),
+        'id' => 5,
+      )
+    );
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+  }
+
+
+  /**
+   * Test basic functionality.
+   */
+  public function testConfigEntityQuery() {
+    // Run a test without any condition.
+    $this->queryResults = $this->factory->get('config_test')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), count($this->entities));
+
+    // Filter by ID with equality.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('id', 3)
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+
+    // Filter by label with a known prefix.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_prefix', 'STARTS_WITH')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+    $this->assertEqual($this->queryResults[3], '3');
+
+    // Filter by label with a known suffix.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_suffix', 'ENDS_WITH')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+    $this->assertEqual($this->queryResults[4], 4);
+
+    // Filter by label with a known containing word.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_contains', 'CONTAINS')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+    $this->assertEqual($this->queryResults[5], 5);
+
+    // Filter by ID with the IN operator.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('id', array(2, 3), 'IN')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 2);
+    $this->assertEqual(array_keys($this->queryResults), array(2, 3));
+
+    // Filter by two conditions on the same field.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_pref', 'STARTS_WITH')
+      ->condition('label', 'test_prefix', 'STARTS_WITH')
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+    $this->assertEqual($this->queryResults[3], 3);
+
+    // Filter by two conditions on different fields.
+    // the first query matches for a different ID, so the result is empty.
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_prefix', 'STARTS_WITH')
+      ->condition('id', 5)
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 0);
+
+    $this->queryResults = $this->factory->get('config_test')
+      ->condition('label', 'test_prefix', 'STARTS_WITH')
+      ->condition('id', 3)
+      ->execute();
+
+    $this->assertEqual(count($this->queryResults), 1);
+    $this->assertEqual($this->queryResults[3], 3);
+
+    // Filter with an OR condition group.
+    $this->queryResults = $this->factory->get('config_test', 'OR')
+      ->condition('id', 1)
+      ->condition('id', 2)
+      ->execute();
+    $this->assertEqual(count($this->queryResults), 2);
+
+    // Filters an OR condition group which both contain an AND group.
+    $query = $this->factory->get('config_test', 'OR');
+    $and_condition_1 = $query->andConditionGroup()
+      ->condition('id', 1)
+      ->condition('label', $this->entities[0]->label);
+    $and_condition_2 = $query->andConditionGroup()
+      ->condition('id', 2)
+      ->condition('label', $this->entities[1]->label);
+    $this->queryResults = $this->factory->get('config_test', 'OR')
+      ->condition($and_condition_1)
+      ->condition($and_condition_2)
+      ->execute();
+    $this->assertEqual(count($this->queryResults), 2);
+    $this->assertEqual($this->queryResults, array(1 => 1, 2 => 2));
+  }
+
+  /**
+   * Test entity count query.
+   */
+  protected function testPager() {
+    $count = $this->factory->get('config_test')
+      ->count()
+      ->execute();
+
+    $this->assertEqual($count, count($this->entities));
+
+    // Apply a complex query with the count query.
+    $query = $this->factory->get('config_test', 'OR');
+    $and_condition_1 = $query->andConditionGroup()
+      ->condition('id', 1)
+      ->condition('label', $this->entities[0]->label);
+    $and_condition_2 = $query->andConditionGroup()
+      ->condition('id', 2)
+      ->condition('label', $this->entities[1]->label);
+    $this->queryResults = $this->factory->get('config_test', 'OR')
+      ->condition($and_condition_1)
+      ->condition($and_condition_2)
+      ->count()
+      ->execute();
+    $this->assertEqual($this->queryResults, 2);
+
+    // Add a range to a query without a start parameter.
+    $this->queryResults = $this->factory->get('config_test')
+      ->range(0, 3)
+      ->execute();
+    $this->assertEqual(count($this->queryResults), 3);
+    $this->assertEqual($this->queryResults, array(1 => 1, 2 => 2, 3 => 3));
+
+    // Add a range with a start parameter.
+    $this->queryResults = $this->factory->get('config_test')
+      ->range(2, 3)
+      ->execute();
+    $this->assertEqual(count($this->queryResults), 3);
+    $this->assertEqual($this->queryResults, array(3 => 3, 4 => 4, 5 => 5));
+
+    // Apply a pager with limit 4.
+    $this->queryResults = $this->factory->get('config_test')
+      ->pager(4, 0)
+      ->execute();
+    $this->assertEqual(count($this->queryResults), 4);
+    $this->assertEqual($this->queryResults, array(1 => 1, 2 => 2, 3 => 3, 4 => 4));
+  }
+
+}
diff --git a/core/modules/filter/filter.info b/core/modules/filter/filter.info
index 03ed179..04ca94f 100644
--- a/core/modules/filter/filter.info
+++ b/core/modules/filter/filter.info
@@ -5,3 +5,4 @@ version = VERSION
 core = 8.x
 required = TRUE
 configure = admin/config/content/formats
+dependencies[] = entity
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index c0e3fe6..c6ae924 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2203,10 +2203,11 @@ function system_update_8046() {
     update_module_enable(array('views'));
 
     // Register views to the container, so views can use it's services.
-    $module_list = drupal_container()->getParameter('container.modules');
+    $module_filenames = drupal_container()->getParameter('container.modules');
+    $module_filenames['views'] = 'core/modules/views/views.module';
     drupal_load('module', 'views');
 
-    drupal_container()->get('kernel')->updateModules(array_keys($module_list), array('views' => 'core/modules/views/views.module'));
+    drupal_container()->get('kernel')->updateModules($module_filenames, $module_filenames);
 
     // This does not fire a hook just calls views.
     config_install_default_config('module', 'views');
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index ff5a0e2..6d881ad 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -656,7 +656,12 @@ function user_update_8011() {
   // User pictures can only be migrated to the new user picture image field
   // if Image module is installed.
   if (!module_exists('image')) {
-    module_enable(array('image'));
+    update_module_enable(array('image'));
+
+    // This does not fire a hook just calls image.
+    drupal_load('module', 'image');
+    config_install_default_config('module', 'image');
+    drupal_container()->get('keyvalue')->get('system.schema')->set('image', 8002);
   }
 
   if ($default_image = update_variable_get('user_picture_default', '')) {
