diff --git a/nodeorder.info.yml b/nodeorder.info.yml
index 5b021e7..da89d17 100644
--- a/nodeorder.info.yml
+++ b/nodeorder.info.yml
@@ -1,6 +1,7 @@
 name: 'Node Order'
 description: 'Allows the ordering of nodes within taxonomy terms.'
 core: 8.x
+core_version_requirement: ^8 || ^9
 configure: nodeorder.admin
 dependencies:
   - drupal:node
diff --git a/nodeorder.install b/nodeorder.install
index fa397f4..424282e 100644
--- a/nodeorder.install
+++ b/nodeorder.install
@@ -28,7 +28,7 @@ function nodeorder_install() {
   $keys['fields']['weight'] = $spec;
 
   // Add the column to the table.
-  db_add_field('taxonomy_index', 'weight', $spec, $keys);
+  \Drupal::database()->schema()->addField('taxonomy_index', 'weight', $spec, $keys);
 
   // Set the weight of the nodeorder module ensure that nodeorder can alter
   // forms after the taxonomy module.
@@ -41,6 +41,6 @@ function nodeorder_install() {
  * Drops field 'weight' from core table 'taxonomy_index'.
  */
 function nodeorder_uninstall() {
-  db_drop_index('taxonomy_index', 'weight');
-  db_drop_field('taxonomy_index', 'weight');
+  \Drupal::database()->schema()->dropIndex('taxonomy_index', 'weight');
+  \Drupal::database()->schema()->dropField('taxonomy_index', 'weight');
 }
diff --git a/nodeorder.module b/nodeorder.module
index a16423f..aab3921 100755
--- a/nodeorder.module
+++ b/nodeorder.module
@@ -9,7 +9,6 @@ use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
 use Drupal\node\NodeInterface;
-use Drupal\taxonomy\Entity\Vocabulary;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\taxonomy\Entity\Term;
@@ -110,7 +109,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
       $order = 'n.sticky DESC, tn0.weight';
 
       $tid = 0;
-      $query_max = db_select('taxonomy_index', 'ti')
+      $query_max = \Drupal::database()->select('taxonomy_index', 'ti')
         ->condition('tid', $tid);
       $query_max->addExpression('MAX(weight)', 'mweight');
 
@@ -122,7 +121,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
         foreach ($result as $node) {
           $max = $query_max->execute()->fetchField();
           $max = (int) $max + 1;
-          db_update('taxonomy_index')
+          \Drupal::database()->update('taxonomy_index')
             ->condition('nid', $node->nid)
             ->condition('tid', $tid)
             ->fields(['weight' => $max])
@@ -131,7 +130,7 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
       }
     }
 
-    drupal_set_message(t('You may now order nodes within this vocabulary.'));
+    \Drupal::messenger()->addMessage(t('You may now order nodes within this vocabulary.'));
   }
   elseif (!$orderable && !empty($vocabularies[$vocabulary->id()])) {
     // Switching from orderable to non-orderable.
@@ -146,13 +145,13 @@ function nodeorder_taxonomy_vocabulary_form_submit($form, FormStateInterface $fo
     }
 
     if (count($tids) > 0) {
-      db_update('taxonomy_index')
+      \Drupal::database()->update('taxonomy_index')
         ->fields(['weight' => 0])
         ->condition('tid', $tids, 'IN')
         ->execute();
     }
 
-    drupal_set_message(t('You may no longer order nodes within this vocabulary.'));
+    \Drupal::messenger()->addMessage(t('You may no longer order nodes within this vocabulary.'));
   }
 
   // Update config.
@@ -173,7 +172,7 @@ function nodeorder_node_presave(NodeInterface $node) {
     $node->nodeorder = [];
     // When a node is created, store an element called 'nodeorder' that
     // contains an associative array of tid to weight.
-    $query = db_select('taxonomy_index', 'ti')
+    $query = \Drupal::database()->select('taxonomy_index', 'ti')
       ->fields('ti', ['tid', 'weight'])
       ->condition('nid', $node->id());
     $result = $query->execute();
@@ -237,7 +236,7 @@ function nodeorder_node_update(NodeInterface $node) {
       if (!$old_weight) {
         continue;
       }
-      db_update('taxonomy_index')
+      \Drupal::database()->update('taxonomy_index')
         ->fields(['weight' => $old_weight])
         ->condition('nid', $node->id())
         ->condition('tid', $tid)
diff --git a/nodeorder.services.yml b/nodeorder.services.yml
index 527e0c1..b97218d 100755
--- a/nodeorder.services.yml
+++ b/nodeorder.services.yml
@@ -1,4 +1,4 @@
 services:
   nodeorder.manager:
     class: Drupal\nodeorder\NodeOrderManager
-    arguments: ['@config.factory', '@entity.manager', '@cache.default']
+    arguments: ['@config.factory', '@entity_type.manager', '@cache.default', '@database']
diff --git a/src/NodeOrderListBuilder.php b/src/NodeOrderListBuilder.php
index 272c146..b9b8b26 100644
--- a/src/NodeOrderListBuilder.php
+++ b/src/NodeOrderListBuilder.php
@@ -289,7 +289,7 @@ class NodeOrderListBuilder extends EntityListBuilder implements FormInterface {
       }
     }
 
-    drupal_set_message($this->t('The node orders have been updated.'));
+    $this->messenger()->addMessage($this->t('The node orders have been updated.'));
 
     if (!empty($tags)) {
       $this->cacheTagsInvalidator->invalidateTags($tags);
diff --git a/src/NodeOrderManager.php b/src/NodeOrderManager.php
index bbb1626..3e415a9 100644
--- a/src/NodeOrderManager.php
+++ b/src/NodeOrderManager.php
@@ -6,8 +6,10 @@ use Drupal\Core\Cache\Cache;
 use Drupal\node\NodeInterface;
 use Drupal\taxonomy\Entity\Vocabulary;
 use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeManager;
 use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Database\Connection;
 
 /**
  * Defines a service that creates & manages node ordering within taxonomy terms.
@@ -35,20 +37,28 @@ class NodeOrderManager implements NodeOrderManagerInterface {
    */
   protected $cache;
 
+  /**
+   * Database connection.
+   *
+   * @var \Drupal\Core\Database\Connection
+   */
+  protected $connection;
+
   /**
    * Constructs a NodeOrderManager object.
    *
    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    *   The configuration object factory.
-   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
    *   The entity manager.
    * @param \Drupal\Core\Cache\CacheBackendInterface $cache
    *   Default cache bin.
    */
-  public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, CacheBackendInterface $cache) {
+  public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, CacheBackendInterface $cache, Connection $connection) {
     $this->configFactory = $config_factory;
-    $this->termStorage = $entity_manager->getStorage('taxonomy_term');
+    $this->termStorage = $entity_type_manager->getStorage('taxonomy_term');
     $this->cache = $cache;
+    $this->connection = $connection;
   }
 
   /**
@@ -57,7 +67,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
   public function addToList(NodeInterface $node, $tid) {
     // Append new orderable node. Get the cached weights.
     $weights = $this->getTermMinMax($tid);
-    db_update('taxonomy_index')
+    $this->connection->update('taxonomy_index')
       ->fields(['weight' => $weights['min'] - 1])
       ->condition('nid', $node->id())
       ->condition('tid', $tid)
@@ -65,7 +75,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     // If new node out of range, push top nodes down filling the order gap
     // this is when old list's min weight is top range
     // except when new orderable node increases range (new list is not even).
-    $taxonomy_nids = db_select('taxonomy_index', 'ti')
+    $taxonomy_nids = $this->connection->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid'])
       ->condition('ti.tid', $tid)
       ->orderBy('ti.weight')
@@ -79,7 +89,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
       $top_range_nids = [];
       $previous_weight = $weights['min'] - 2;
       foreach ($taxonomy_nids as $taxonomy_nid) {
-        $taxonomy_node_weight = db_select('taxonomy_index', 'i')
+        $taxonomy_node_weight = $this->connection->select('taxonomy_index', 'i')
           ->fields('i', ['weight'])
           ->condition('tid', $tid)
           ->condition('nid', $taxonomy_nid)
@@ -93,7 +103,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
         $top_range_nids[] = $taxonomy_nid;
       }
       // Move top nodes down.
-      $query = db_update('taxonomy_index');
+      $query = $this->connection->update('taxonomy_index');
       $query->expression('weight', 'weight + 1');
       $query->condition('nid', $top_range_nids, 'IN')
         ->condition('tid', $tid)
@@ -124,7 +134,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     }
 
     if (!isset($min_weights[$tid]) || !isset($max_weights[$tid])) {
-      $query = db_select('taxonomy_index', 'i')
+      $query = $this->connection->select('taxonomy_index', 'i')
         ->fields('i', ['tid'])
         ->condition('tid', $tid)
         ->groupBy('tid');
@@ -177,7 +187,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
       }
       else {
         $args = [];
-        $query = db_select('node', 'n');
+        $query = $this->connection->select('node', 'n');
         $query->join('node_field_data', 'nd');
         $query->condition('nd.status', 1);
         foreach ($descendant_tids as $index => $tids) {
@@ -209,7 +219,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
         }
         else {
           // TODO Please convert this statement to the D7 database API syntax.
-          $result = db_query_range($sql, $args);
+          $result = $this->connection->queryRange($sql, $args);
         }
       }
     }
@@ -270,7 +280,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
         }
       }
       if (!empty($vocabularies)) {
-        $query = db_select('taxonomy_index', 'i');
+        $query = $this->connection->select('taxonomy_index', 'i');
         $query->join('taxonomy_term_data', 'd', 'd.tid = i.tid');
         $query->condition('i.nid', $node->id())
           ->condition('d.vid', $vocabularies, 'IN')
@@ -317,7 +327,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
    * {@inheritdoc}
    */
   public function handleListsDecrease($tid) {
-    $taxonomy_nids = db_select('taxonomy_index', 'ti')
+    $taxonomy_nids = $this->connection->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid'])
       ->condition('ti.tid', $tid)
       ->orderBy('ti.weight')
@@ -334,7 +344,7 @@ class NodeOrderManager implements NodeOrderManagerInterface {
     if ($border_out_of_range) {
       $weight = -$range_border;
       foreach ($taxonomy_nids as $nid) {
-        db_update('taxonomy_index')
+        $this->connection->update('taxonomy_index')
           ->fields(['weight' => $weight])
           ->condition('nid', $nid)
           ->condition('tid', $tid)
diff --git a/src/Tests/NodeorderCrudTest.php b/src/Tests/NodeorderCrudTest.php
index 8bbf872..fb1c372 100644
--- a/src/Tests/NodeorderCrudTest.php
+++ b/src/Tests/NodeorderCrudTest.php
@@ -3,7 +3,9 @@
 namespace Drupal\nodeorder\Tests;
 
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
-use Drupal\taxonomy\Tests\TaxonomyTestBase;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase;
 
 /**
  * Test CRUD operations that Nodeorder relies on.
@@ -54,7 +56,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
     $this->vocabulary = $this->createVocabulary();
 
     $field_name = 'taxonomy_' . $this->vocabulary->id();
-    entity_create('field_storage_config', [
+    FieldStorageConfig::create([
       'field_name' => $field_name,
       'entity_type' => 'node',
       'type' => 'entity_reference',
@@ -65,7 +67,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
       ],
     ])->save();
 
-    $this->field = entity_create('field_config', [
+    $this->field = FieldConfig::create([
       'field_name' => $field_name,
       'bundle' => 'article',
       'entity_type' => 'node',
@@ -83,12 +85,12 @@ class NodeorderCrudTest extends TaxonomyTestBase {
       ],
     ]);
     $this->field->save();
-    entity_get_form_display('node', 'article', 'default')
+    \Drupal::service('entity_display.repository')->getFormDisplay('node', 'article', 'default')
       ->setComponent($field_name, [
         'type' => 'options_select',
       ])
       ->save();
-    entity_get_display('node', 'article', 'default')
+    \Drupal::service('entity_display.repository')->getViewDisplay('node', 'article', 'default')
       ->setComponent($field_name, [
         'type' => 'entity_reference_label',
       ])
@@ -296,7 +298,7 @@ class NodeorderCrudTest extends TaxonomyTestBase {
    *   Expected order keyed by node ID.
    */
   protected function assertNodeorderByTid($tid, array $expected) {
-    $order = db_select('taxonomy_index', 'ti')
+    $order = \Drupal::database()->select('taxonomy_index', 'ti')
       ->fields('ti', ['nid', 'weight'])
       ->condition('tid', $tid)
       ->execute()
