diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php
index 5387c7e..3e7cc0c 100644
--- a/core/lib/Drupal/Core/Entity/entity.api.php
+++ b/core/lib/Drupal/Core/Entity/entity.api.php
@@ -1202,10 +1202,10 @@ function hook_ENTITY_TYPE_predelete(Drupal\Core\Entity\EntityInterface $entity)
  */
 function hook_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
   // Delete the entity's entry from a fictional table of all entities.
-  db_delete('example_entity')
-    ->condition('type', $entity->getEntityTypeId())
-    ->condition('id', $entity->id())
-    ->execute();
+  $query = \Drupal::database()->delete('example_entity');
+  $query->condition('type',$entity->getEntityTypeId());
+  $query->condition('id',$entity->id());
+  $query->execute();
 }
 
 /**
@@ -1221,10 +1221,10 @@ function hook_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
  */
 function hook_ENTITY_TYPE_delete(Drupal\Core\Entity\EntityInterface $entity) {
   // Delete the entity's entry from a fictional table of all entities.
-  db_delete('example_entity')
-    ->condition('type', $entity->getEntityTypeId())
-    ->condition('id', $entity->id())
-    ->execute();
+  $query = \Drupal::database()->delete('example_entity');
+  $query->condition('type',$entity->getEntityTypeId());
+  $query->condition('id',$entity->id());
+  $query->execute();
 }
 
 /**
diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
index 2500b9e..0221fb9 100644
--- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
@@ -83,7 +83,7 @@ protected function submitImportForm() {
     $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
 
-    db_delete('aggregator_feed')->execute();
+    \Drupal::database()->delete('aggregator_feed')->execute();
 
     $feeds[0] = $this->getFeedEditArray();
     $feeds[1] = $this->getFeedEditArray();
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index ed92d6c..f1fbcf8 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -73,9 +73,9 @@ function dblog_cron() {
 
     // Delete all table entries older than the nth row, if nth row was found.
     if ($min_row) {
-      db_delete('watchdog')
-        ->condition('wid', $min_row, '<')
-        ->execute();
+      $query = \Drupal::database()->delete('watchdog');
+      $query->condition('wid', $min_row, '<');
+      $query->execute();
     }
   }
 }
diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php
index 79cc038..28e066b 100644
--- a/core/modules/dblog/src/Tests/DbLogTest.php
+++ b/core/modules/dblog/src/Tests/DbLogTest.php
@@ -602,7 +602,7 @@ public function testFilter() {
     $this->drupalLogin($this->adminUser);
 
     // Clear the log to ensure that only generated entries will be found.
-    db_delete('watchdog')->execute();
+    \Drupal::database()->delete('watchdog')->execute();
 
     // Generate 9 random watchdog entries.
     $type_names = [];
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index b0899ea..b47a795 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -283,9 +283,9 @@ function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mo
  *   The field storage being purged.
  */
 function hook_field_purge_field_storage(\Drupal\field\Entity\FieldStorageConfig $field_storage) {
-  db_delete('my_module_field_storage_info')
-    ->condition('uuid', $field_storage->uuid())
-    ->execute();
+  $query = \Drupal::database()->delete('my_module_field_storage_info');
+  $query->condition('uuid', $field_storage->uuid());
+  $query->execute();
 }
 
 /**
@@ -300,9 +300,9 @@ function hook_field_purge_field_storage(\Drupal\field\Entity\FieldStorageConfig
  *   The field being purged.
  */
 function hook_field_purge_field(\Drupal\field\Entity\FieldConfig $field) {
-  db_delete('my_module_field_info')
-    ->condition('id', $field->id())
-    ->execute();
+  $query = \Drupal::database()->delete('my_module_field_info');
+  $query->condition('id', $field->id());
+  $query->execute();
 }
 
 /**
diff --git a/core/modules/history/history.module b/core/modules/history/history.module
index f36121e..dda95d6 100644
--- a/core/modules/history/history.module
+++ b/core/modules/history/history.module
@@ -124,9 +124,9 @@ function history_write($nid, $account = NULL) {
  * Implements hook_cron().
  */
 function history_cron() {
-  db_delete('history')
-    ->condition('timestamp', HISTORY_READ_LIMIT, '<')
-    ->execute();
+  $query = \Drupal::database()->delete('history');
+  $query->condition('timestamp', HISTORY_READ_LIMIT, '<');
+  $query->execute();
 }
 
 /**
@@ -151,9 +151,9 @@ function history_node_view_alter(array &$build, EntityInterface $node, EntityVie
  * Implements hook_ENTITY_TYPE_delete() for node entities.
  */
 function history_node_delete(EntityInterface $node) {
-  db_delete('history')
-    ->condition('nid', $node->id())
-    ->execute();
+  $query = \Drupal::database()->delete('history');
+  $query->condition('nid', $node->id());
+  $query->execute();
 }
 
 /**
@@ -162,9 +162,9 @@ function history_node_delete(EntityInterface $node) {
 function history_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
-      db_delete('history')
-        ->condition('uid', $account->id())
-        ->execute();
+      $query = \Drupal::database()->delete('history');
+      $query->condition('uid', $account->id());
+      $query->execute();
       break;
   }
 }
@@ -173,9 +173,9 @@ function history_user_cancel($edit, $account, $method) {
  * Implements hook_ENTITY_TYPE_delete() for user entities.
  */
 function history_user_delete($account) {
-  db_delete('history')
-    ->condition('uid', $account->id())
-    ->execute();
+  $query = \Drupal::database()->delete('history');
+  $query->condition('uid', $account->id());
+  $query->execute();
 }
 
 /**
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index b1298e4..984904a 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -864,7 +864,7 @@ function locale_translation_update_file_history($file) {
  *   Language code(s) to be deleted from the file history.
  */
 function locale_translation_file_history_delete($projects = [], $langcodes = []) {
-  $query = db_delete('locale_file');
+  $query = \Drupal::database()->delete('locale_file');
   if (!empty($projects)) {
     $query->condition('project', $projects, 'IN');
   }
diff --git a/core/modules/path/path.api.php b/core/modules/path/path.api.php
index df20b95..d786b13 100644
--- a/core/modules/path/path.api.php
+++ b/core/modules/path/path.api.php
@@ -56,9 +56,9 @@ function hook_path_update($path) {
  * @see \Drupal\Core\Path\PathInterface::delete()
  */
 function hook_path_delete($path) {
-  db_delete('mytable')
-    ->condition('pid', $path['pid'])
-    ->execute();
+  $query = \Drupal::database()->delete('mytable');
+  $query->condition('pid', $path['pid']);
+  $query->execute();
 }
 
 /**
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index ae99a87..84bfe65 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -133,8 +133,8 @@ function search_preprocess_block(&$variables) {
  *   omitted, all items matching $sid and $type are cleared.
  */
 function search_index_clear($type = NULL, $sid = NULL, $langcode = NULL) {
-  $query_index = db_delete('search_index');
-  $query_dataset = db_delete('search_dataset');
+  $query_index = \Drupal::database()->delete('search_index');
+  $query_dataset = \Drupal::database()->delete('search_dataset');
   if ($type) {
     $query_index->condition('type', $type);
     $query_dataset->condition('type', $type);
@@ -224,9 +224,9 @@ function search_update_totals() {
     $or->condition('word', $word->realword);
   }
   if (count($or) > 0) {
-    db_delete('search_total')
-      ->condition($or)
-      ->execute();
+    $query = \Drupal::database()->delete('search_total');
+    $query->condition($or);
+    $query->execute();
   }
 }
 
diff --git a/core/modules/shortcut/src/ShortcutSetStorage.php b/core/modules/shortcut/src/ShortcutSetStorage.php
index b136c2f..ce7f2f8 100644
--- a/core/modules/shortcut/src/ShortcutSetStorage.php
+++ b/core/modules/shortcut/src/ShortcutSetStorage.php
@@ -9,6 +9,7 @@
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Database\Connection;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -24,6 +25,13 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
   protected $moduleHandler;
 
   /**
+   * The database connection.
+   *
+   * @var \Drupal\Core\Database\Connection
+   */
+  protected $database;
+
+  /**
    * Constructs a ShortcutSetStorageController object.
    *
    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
@@ -37,10 +45,11 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora
    * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
    *   The language manager.
    */
-  public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) {
+  public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager, Connection $database) {
     parent::__construct($entity_info, $config_factory, $uuid_service, $language_manager);
 
     $this->moduleHandler = $module_handler;
+    $this->database = $database;
   }
 
   /**
@@ -52,7 +61,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
       $container->get('config.factory'),
       $container->get('uuid'),
       $container->get('module_handler'),
-      $container->get('language_manager')
+      $container->get('language_manager'),
+      $container->get('database')
     );
   }
 
@@ -62,9 +72,9 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
   public function deleteAssignedShortcutSets(ShortcutSetInterface $entity) {
     // First, delete any user assignments for this set, so that each of these
     // users will go back to using whatever default set applies.
-    db_delete('shortcut_set_users')
-      ->condition('set_name', $entity->id())
-      ->execute();
+    $query = $this->database->delete('shortcut_set_users');
+    $query->condition('set_name', $entity->id());
+    $query->execute();
   }
 
   /**
@@ -82,9 +92,9 @@ public function assignUser(ShortcutSetInterface $shortcut_set, $account) {
    * {@inheritdoc}
    */
   public function unassignUser($account) {
-    $deleted = db_delete('shortcut_set_users')
-      ->condition('uid', $account->id())
-      ->execute();
+    $deleted = $this->database->delete('shortcut_set_users');
+    $deleted->condition('uid', $account->id());
+    $deleted->execute();
     return (bool) $deleted;
   }
 
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 4a93989..f6a2b34 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -567,7 +567,9 @@ function taxonomy_node_predelete(EntityInterface $node) {
  */
 function taxonomy_delete_node_index(EntityInterface $node) {
   if (\Drupal::config('taxonomy.settings')->get('maintain_index_table')) {
-    db_delete('taxonomy_index')->condition('nid', $node->id())->execute();
+    $query = \Drupal::database()->delete('taxonomy_index');
+    $query->condition('nid', $node->id());
+    $query->execute();
   }
 }
 
@@ -577,7 +579,9 @@ function taxonomy_delete_node_index(EntityInterface $node) {
 function taxonomy_taxonomy_term_delete(Term $term) {
   if (\Drupal::config('taxonomy.settings')->get('maintain_index_table')) {
     // Clean up the {taxonomy_index} table when terms are deleted.
-    db_delete('taxonomy_index')->condition('tid', $term->id())->execute();
+    $query = \Drupal::database()->delete('taxonomy_index');
+    $query->condition('nid', $term->id());
+    $query->execute();
   }
 }
 
diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php
index 17f95ee..71fa1a4 100644
--- a/core/modules/tracker/tests/src/Functional/TrackerTest.php
+++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php
@@ -365,9 +365,9 @@ public function testTrackerCronIndexing() {
     \Drupal::state()->set('tracker.index_nid', 3);
 
     // Clear the current tracker tables and rebuild them.
-    db_delete('tracker_node')
+    \Drupal::database()->delete('tracker_node')
       ->execute();
-    db_delete('tracker_user')
+    \Drupal::database()->delete('tracker_user')
       ->execute();
     tracker_cron();
 
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index dbde704..c716b37 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -61,12 +61,13 @@ function tracker_cron() {
       $changed = _tracker_calculate_changed($node);
 
       // Remove existing data for this node.
-      db_delete('tracker_node')
-        ->condition('nid', $nid)
-        ->execute();
-      db_delete('tracker_user')
-        ->condition('nid', $nid)
-        ->execute();
+      $query = \Drupal::database()->delete('tracker_node');
+      $query->condition('nid',$nid);
+      $query->execute();
+
+      $query = \Drupal::database()->delete('tracker_user');
+      $query->condition('nid',$nid);
+      $query->execute();
 
       // Insert the node-level data.
       db_insert('tracker_node')
@@ -189,12 +190,13 @@ function tracker_node_update(NodeInterface $node, $arg = 0) {
  * Deletes tracking information for a node.
  */
 function tracker_node_predelete(EntityInterface $node, $arg = 0) {
-  db_delete('tracker_node')
-    ->condition('nid', $node->id())
-    ->execute();
-  db_delete('tracker_user')
-    ->condition('nid', $node->id())
-    ->execute();
+  $query = \Drupal::database()->delete('tracker_node');
+  $query->condition('nid',$node->id());
+  $query->execute();
+
+  $query = \Drupal::database()->delete('tracker_user');
+  $query->condition('nid',$node->id());
+  $query->execute();
 }
 
 /**
@@ -333,10 +335,10 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
 
     // If we haven't found a reason to keep the user's subscription, delete it.
     if (!$keep_subscription) {
-      db_delete('tracker_user')
-        ->condition('nid', $nid)
-        ->condition('uid', $uid)
-        ->execute();
+      $query = \Drupal::database()->delete('tracker_user');
+      $query->condition('nid',$nid);
+      $query->condition('uid',$uid);
+      $query->execute();
     }
 
     // Now we need to update the (possibly) changed timestamps for other users
@@ -371,11 +373,12 @@ function _tracker_remove($nid, $uid = NULL, $changed = NULL) {
   }
   else {
     // If the node doesn't exist, remove everything.
-    db_delete('tracker_node')
-      ->condition('nid', $nid)
-      ->execute();
-    db_delete('tracker_user')
-      ->condition('nid', $nid)
-      ->execute();
+    $query = \Drupal::database()->delete('tracker_node');
+    $query->condition('nid',$nid);
+    $query->execute();
+
+    $query = \Drupal::database()->delete('tracker_user');
+    $query->condition('nid',$nid);
+    $query->execute();
   }
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
index 0aecc72..8dee85c 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php
@@ -38,7 +38,7 @@ protected function update($name, $data) {
   }
 
   protected function delete($name) {
-    db_delete('config')->condition('name', $name)->execute();
+    \Drupal::database()->delete('config')->condition('name', $name)->execute();
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
index 8d73661..c83bb88 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
@@ -27,7 +27,7 @@ public function testSubselectDelete() {
     $subquery = db_select('test', 't')
       ->fields('t', ['id'])
       ->condition('t.id', [$pid_to_delete], 'IN');
-    $delete = db_delete('test_task')
+    $delete = \Drupal::database()->delete('test_task')
       ->condition('task', 'sleep')
       ->condition('pid', $subquery, 'IN');
 
@@ -44,7 +44,7 @@ public function testSubselectDelete() {
   public function testSimpleDelete() {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
 
-    $num_deleted = db_delete('test')
+    $num_deleted = \Drupal::database()->delete('test')
       ->condition('id', 1)
       ->execute();
     $this->assertIdentical($num_deleted, 1, 'Deleted 1 record.');
@@ -72,7 +72,7 @@ public function testTruncate() {
   public function testSpecialColumnDelete() {
     $num_records_before = db_query('SELECT COUNT(*) FROM {test_special_columns}')->fetchField();
 
-    $num_deleted = db_delete('test_special_columns')
+    $num_deleted = \Drupal::database()->delete('test_special_columns')
       ->condition('id', 1)
       ->execute();
     $this->assertIdentical($num_deleted, 1, 'Deleted 1 special column record.');
