diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 726f228..f8a511c 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -181,12 +181,10 @@ function aggregator_permission() {
  * Queues news feeds for updates once their refresh interval has elapsed.
  */
 function aggregator_cron() {
-  $result = db_query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
-    ':time' => REQUEST_TIME,
-    ':never' => AGGREGATOR_CLEAR_NEVER
-  ));
   $queue = \Drupal::queue('aggregator_feeds');
-  foreach ($result->fetchCol() as $fid) {
+
+  $result = \Drupal::entityManager()->getStorageController('aggregator_feed')->getFeedIdsToRefresh();
+  foreach ($result as $fid) {
     $feed = aggregator_feed_load($fid);
     if ($queue->createItem($feed)) {
       // Add timestamp to avoid queueing item more than once.
@@ -196,10 +194,17 @@ function aggregator_cron() {
   }
 
   // Remove queued timestamp after 6 hours assuming the update has failed.
-  db_update('aggregator_feed')
-    ->fields(array('queued' => 0))
+  $result = \Drupal::entityQuery('aggregator_feed')
     ->condition('queued', REQUEST_TIME - (3600 * 6), '<')
     ->execute();
+
+  if ($result) {
+    $feeds = entity_load_multiple('aggregator_feed', $result);
+    foreach ($feeds as $feed) {
+      $feed->queued->value = 0;
+      $feed->save();
+    }
+  }
 }
 
 /**
@@ -393,8 +398,9 @@ function aggregator_category_load($cid) {
  */
 function template_preprocess_aggregator_block_item(&$variables) {
   // Display the external link to the item.
-  $variables['url'] = check_url($variables['item']->link);
-  $variables['title'] = check_plain($variables['item']->title);
+  $item = $variables['item'];
+  $variables['url'] = check_url($item->getLink());
+  $variables['title'] = check_plain($item->getTitle());
 }
 
 /**
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
index 1b85a89..11956a1 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\aggregator\Controller;
 
+use Drupal\aggregator\FeedStorageControllerInterface;
+
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
 use Drupal\aggregator\CategoryStorageControllerInterface;
@@ -38,6 +40,13 @@ class AggregatorController extends ControllerBase implements ContainerInjectionI
   protected $categoryStorage;
 
   /**
+   * The feed storage controller.
+   *
+   * @var \Drupal\aggregator\FeedStorageControllerInterface
+   */
+  protected $feedStorage;
+
+  /**
    * Constructs a \Drupal\aggregator\Controller\AggregatorController object.
    *
    * @param \Drupal\Core\Database\Connection $database
@@ -45,9 +54,10 @@ class AggregatorController extends ControllerBase implements ContainerInjectionI
    * @param \Drupal\aggregator\CategoryStorageControllerInterface $category_storage
    *   The category storage service.
    */
-  public function __construct(Connection $database, CategoryStorageControllerInterface $category_storage) {
+  public function __construct(Connection $database, CategoryStorageControllerInterface $category_storage, FeedStorageControllerInterface $feed_storage) {
     $this->database = $database;
     $this->categoryStorage = $category_storage;
+    $this->feedStorage = $feed_storage;
   }
 
   /**
@@ -56,7 +66,8 @@ public function __construct(Connection $database, CategoryStorageControllerInter
   public static function create(ContainerInterface $container) {
     return new static(
       $container->get('database'),
-      $container->get('aggregator.category.storage')
+      $container->get('aggregator.category.storage'),
+      $container->get('plugin.manager.entity')->getStorageController('aggregator_feed')
     );
   }
 
@@ -174,37 +185,38 @@ public function feedRefresh(FeedInterface $aggregator_feed, Request $request) {
    *   A render array as expected by drupal_render().
    */
   public function adminOverview() {
-    $result = $this->database->query('SELECT f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image ORDER BY f.title');
+    $feeds = $this->feedStorage->loadMultiple();
 
     $header = array($this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations'));
     $rows = array();
-    foreach ($result as $feed) {
+    foreach ($feeds as $feed) {
       $row = array();
-      $row[] = l($feed->title, "aggregator/sources/$feed->fid");
-      $row[] = format_plural($feed->items, '1 item', '@count items');
-      $row[] = ($feed->checked ? $this->t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked))) : $this->t('never'));
-      $row[] = ($feed->checked && $feed->refresh ? $this->t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - REQUEST_TIME))) : $this->t('never'));
+      $row[] = l($feed->title->value, "aggregator/sources/" . $feed->fid->value);
+      $row[] = format_plural($this->feedStorage->getItemCount($feed), '1 item', '@count items');
+      $row[] = ($feed->checked->value ? $this->t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked->value))) : $this->t('never'));
+      $row[] = ($feed->checked->value && $feed->refresh->value ? $this->t('%time left', array('%time' => format_interval($feed->checked->value + $feed->refresh->value - REQUEST_TIME))) : $this->t('never'));
+
       $links = array();
       $links['edit'] = array(
         'title' => $this->t('Edit'),
         'route_name' => 'aggregator.feed_edit',
-        'route_parameters' => array('aggregator_feed' => $feed->fid),
+        'route_parameters' => array('aggregator_feed' => $feed->id()),
       );
       $links['delete'] = array(
         'title' => $this->t('Delete'),
         'route_name' => 'aggregator.feed_delete',
-        'route_parameters' => array('aggregator_feed' => $feed->fid),
+        'route_parameters' => array('aggregator_feed' => $feed->id()),
       );
       $links['remove'] = array(
         'title' => $this->t('Remove items'),
         'route_name' => 'aggregator.feed_items_delete',
-        'route_parameters' => array('aggregator_feed' => $feed->fid),
+        'route_parameters' => array('aggregator_feed' => $feed->id()),
       );
       $links['update'] = array(
         'title' => $this->t('Update items'),
         'route_name' => 'aggregator.feed_refresh',
-        'route_parameters' => array('aggregator_feed' => $feed->fid),
-        'query' => array('token' => drupal_get_token("aggregator/update/$feed->fid")),
+        'route_parameters' => array('aggregator_feed' => $feed->id()),
+        'query' => array('token' => drupal_get_token("aggregator/update/{$feed->id()}")),
       );
       $row[] = array(
         'data' => array(
@@ -224,7 +236,11 @@ public function adminOverview() {
 
     $result = $this->database->query('SELECT c.cid, c.title, COUNT(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
 
-    $header = array($this->t('Title'), $this->t('Items'), $this->t('Operations'));
+    $header = array(
+      $this->t('Title'),
+      $this->t('Items'),
+      $this->t('Operations')
+    );
     $rows = array();
     foreach ($result as $category) {
       $row = array();
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php
index 8f8fd71..85e3b05 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php
@@ -75,4 +75,20 @@ public function getFeedDuplicates(FeedInterface $feed) {
     return $query->fetchAll();
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getItemCount(FeedInterface $feed) {
+    return $this->database->query("SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid", array(':fid' => $feed->id()))->fetchField();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFeedIdsToRefresh() {
+    return $this->database->query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
+      ':time' => REQUEST_TIME,
+      ':never' => AGGREGATOR_CLEAR_NEVER
+    ))->fetchCol();
+  }
 }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php
index ab33938..f5e5e6a 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageControllerInterface.php
@@ -53,4 +53,19 @@ public function deleteCategories(array $feeds);
    */
   public function getFeedDuplicates(FeedInterface $feed);
 
+  /**
+   * Returns the count of the items in the feed.
+   *
+   * @param Feed $feed
+   *   The feed entity.
+   */
+  public function getItemCount(FeedInterface $feed);
+
+  /**
+   * Returns the fids of feed that need to be refreshed.
+   *
+   *  @return array
+   *    A list of feeds to be refreshed.
+   */
+  public function getFeedIdsToRefresh();
 }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorCategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorCategoryBlock.php
index 980424c..4a0233b 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorCategoryBlock.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorCategoryBlock.php
@@ -8,6 +8,7 @@
 namespace Drupal\aggregator\Plugin\Block;
 
 use Drupal\aggregator\CategoryStorageControllerInterface;
+use Drupal\aggregator\ItemStorageControllerInterface;
 use Drupal\block\BlockBase;
 use Drupal\block\Annotation\Block;
 use Drupal\Core\Annotation\Translation;
@@ -42,6 +43,13 @@ class AggregatorCategoryBlock extends BlockBase implements ContainerFactoryPlugi
   protected $categoryStorageController;
 
   /**
+   * The item storage controller.
+   *
+   * @var \Drupal\aggregator\ItemStorageControllerInterface
+   */
+  protected $itemStorageController;
+
+  /**
    * Constructs an AggregatorFeedBlock object.
    *
    * @param array $configuration
@@ -53,10 +61,11 @@ class AggregatorCategoryBlock extends BlockBase implements ContainerFactoryPlugi
    * @param \Drupal\Core\Database\Connection $connection
    *   The database connection.
    */
-  public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $connection, CategoryStorageControllerInterface $category_storage_controller) {
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $connection, CategoryStorageControllerInterface $category_storage_controller, ItemStorageControllerInterface $item_storage_controller) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->connection = $connection;
     $this->categoryStorageController = $category_storage_controller;
+    $this->itemStorageController = $item_storage_controller;
   }
 
 
@@ -69,7 +78,8 @@ public static function create(ContainerInterface $container, array $configuratio
       $plugin_id,
       $plugin_definition,
       $container->get('database'),
-      $container->get('aggregator.category.storage')
+      $container->get('aggregator.category.storage'),
+      $container->get('plugin.manager.entity')->getStorageController('aggregator_item')
     );
   }
 
@@ -131,7 +141,8 @@ public function blockSubmit($form, &$form_state) {
   public function build() {
     $cid = $this->configuration['cid'];
     if ($category = $this->categoryStorageController->load($cid)) {
-      $result = $this->connection->queryRange('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->configuration['block_count'], array(':cid' => $category->cid));
+      $aggregator_items = $this->itemStorageController->loadByCategory($category->cid, $this->configuration['block_count']);
+
       $more_link = array(
         '#theme' => 'more_link',
         '#url' => 'aggregator/categories/' . $category->cid,
@@ -140,7 +151,7 @@ public function build() {
       $read_more = drupal_render($more_link);
 
       $items = array();
-      foreach ($result as $item) {
+      foreach ($aggregator_items as $item) {
         $aggregator_block_item = array(
           '#theme' => 'aggregator_block_item',
           '#item' => $item,
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
index fa34b8a..81a867f 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
@@ -11,7 +11,9 @@
 use Drupal\block\Annotation\Block;
 use Drupal\Core\Annotation\Translation;
 use Drupal\Core\Database\Connection;
-use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Core\Entity\Query\QueryFactory;
+use Drupal\aggregator\FeedStorageControllerInterface;
+use Drupal\aggregator\ItemStorageControllerInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\Core\Session\AccountInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -30,9 +32,16 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
   /**
    * The entity storage controller for feeds.
    *
-   * @var \Drupal\Core\Entity\EntityStorageControllerInterface
+   * @var \Drupal\aggregator\FeedStorageControllerInterface
    */
-  protected $storageController;
+  protected $feedStorage;
+
+  /**
+   * The entity storage controller for items.
+   *
+   * @var \Drupal\aggregator\ItemStorageControllerInterface
+   */
+  protected $itemStorage;
 
   /**
    * The database connection.
@@ -42,6 +51,13 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
   protected $connection;
 
   /**
+   * The entity query factory service.
+   *
+   * @var \Drupal\Core\Entity\Query\QueryFactory
+   */
+  protected $entityQuery;
+
+  /**
    * Constructs an AggregatorFeedBlock object.
    *
    * @param array $configuration
@@ -55,10 +71,12 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
    * @param \Drupal\Core\Database\Connection $connection
    *   The database connection.
    */
-  public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageControllerInterface $storage_controller, Connection $connection) {
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition, FeedStorageControllerInterface $feed_storage, ItemStorageControllerInterface $item_storage, Connection $connection, QueryFactory $entity_query) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
-    $this->storageController = $storage_controller;
+    $this->feedStorage = $feed_storage;
     $this->connection = $connection;
+    $this->entityQuery = $entity_query;
+    $this->itemStorage = $item_storage;
   }
 
 
@@ -71,7 +89,9 @@ public static function create(ContainerInterface $container, array $configuratio
       $plugin_id,
       $plugin_definition,
       $container->get('plugin.manager.entity')->getStorageController('aggregator_feed'),
-      $container->get('database')
+      $container->get('plugin.manager.entity')->getStorageController('aggregator_item'),
+      $container->get('database'),
+      $container->get('entity.query')
     );
   }
 
@@ -99,7 +119,7 @@ public function access(AccountInterface $account) {
    * Overrides \Drupal\block\BlockBase::blockForm().
    */
   public function blockForm($form, &$form_state) {
-    $feeds = $this->storageController->loadMultiple();
+    $feeds = $this->feedStorage->loadMultiple();
     $options = array();
     foreach ($feeds as $feed) {
       $options[$feed->id()] = $feed->label();
@@ -132,27 +152,35 @@ public function blockSubmit($form, &$form_state) {
    */
   public function build() {
     // Load the selected feed.
-    if ($feed = $this->storageController->load($this->configuration['feed'])) {
-      $result = $this->connection->queryRange("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->configuration['block_count'], array(':fid' => $feed->id()));
+    if ($feed = $this->itemStorage->load($this->configuration['feed'])) {
+      $result = $this->entityQuery->get('aggregator_item')
+        ->condition('fid', $feed->id())
+        ->range(0, $this->configuration['block_count'])
+        ->sort('timestamp', 'DESC')
+        ->sort('iid', 'DESC')
+        ->execute();
+
+      $items = $this->itemStorage->loadMultiple($result);
+
       $more_link = array(
         '#theme' => 'more_link',
         '#url' => 'aggregator/sources/' . $feed->id(),
         '#title' => t("View this feed's recent news."),
       );
       $read_more = drupal_render($more_link);
-      $items = array();
-      foreach ($result as $item) {
+      $rendered_items = array();
+      foreach ($items as $item) {
         $aggregator_block_item = array(
           '#theme' => 'aggregator_block_item',
           '#item' => $item,
         );
-        $items[] = drupal_render($aggregator_block_item);
+        $rendered_items[] = drupal_render($aggregator_block_item);
       }
       // Only display the block if there are items to show.
-      if (count($items) > 0) {
+      if (count($rendered_items) > 0) {
         $item_list = array(
           '#theme' => 'item_list',
-          '#items' => $items,
+          '#items' => $rendered_items,
         );
         return array(
           '#children' => drupal_render($item_list) . $read_more,
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
index 1921f78..0a5599d 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\aggregator\Plugin\aggregator\processor;
 
+use Drupal\aggregator\ItemStorageControllerInterface;
+
 use Drupal\aggregator\Annotation\AggregatorProcessor;
 use Drupal\aggregator\Plugin\AggregatorPluginSettingsBase;
 use Drupal\aggregator\Plugin\ProcessorInterface;
@@ -14,6 +16,7 @@
 use Drupal\Core\Annotation\Translation;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Config\ConfigFactory;
+use Drupal\Core\Entity\Query\QueryFactory;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
@@ -37,6 +40,20 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
    */
   protected $configFactory;
 
+   /**
+   * The entity query factory service.
+   *
+   * @var \Drupal\Core\Entity\Query\QueryFactory
+   */
+  protected $entityQuery;
+
+  /**
+   * The entity storage controller for items.
+   *
+   * @var \Drupal\aggregator\ItemStorageControllerInterface
+   */
+  protected $itemStorage;
+
   /**
    * Constructs a DefaultProcessor object.
    *
@@ -49,8 +66,11 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
    * @param \Drupal\Core\Config\ConfigFactory $config
    *   The configuration factory object.
    */
-  public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactory $config) {
+  public function __construct(array $configuration, $plugin_id, array $plugin_definition, ConfigFactory $config, QueryFactory $entity_query, ItemStorageControllerInterface $item_storage) {
     $this->configFactory = $config;
+    $this->entityQuery = $entity_query;
+    $this->itemStorage = $item_storage;
+
     // @todo Refactor aggregator plugins to ConfigEntity so merging
     //   the configuration here is not needed.
     parent::__construct($configuration + $this->getConfiguration(), $plugin_id, $plugin_definition);
@@ -64,7 +84,9 @@ public static function create(ContainerInterface $container, array $configuratio
       $configuration,
       $plugin_id,
       $plugin_definition,
-      $container->get('config.factory')
+      $container->get('config.factory'),
+      $container->get('entity.query'),
+      $container->get('plugin.manager.entity')->getStorageController('aggregator_item')
     );
   }
 
@@ -190,9 +212,12 @@ public function process(Feed $feed) {
    * {@inheritdoc}
    */
   public function remove(Feed $feed) {
-    $iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchCol();
-    if ($iids) {
-      entity_delete_multiple('aggregator_item', $iids);
+    $result = $this->entityQuery->get('aggregator_item')
+      ->condition('fid', $feed->id())
+      ->execute();
+    if ($result) {
+      $entities = $this->itemStorage->loadMultiple($result);
+      $this->itemStorage->delete($entities);
     }
     // @todo This should be moved out to caller with a different message maybe.
     drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->label())));
@@ -209,13 +234,13 @@ public function postProcess(Feed $feed) {
     if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
       // Remove all items that are older than flush item timer.
       $age = REQUEST_TIME - $aggregator_clear;
-      $iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
-        ':fid' => $feed->id(),
-        ':timestamp' => $age,
-      ))
-      ->fetchCol();
-      if ($iids) {
-        entity_delete_multiple('aggregator_item', $iids);
+      $result = $this->entityQuery->get('aggregator_item')
+        ->condition('fid', $feed->id())
+        ->condition('timestamp', $age, '<')
+        ->execute();
+      if ($result) {
+        $entities = $this->itemStorage->loadMultiple($result);
+        $this->itemStorage->delete($entities);
       }
     }
   }
