diff --git a/extensions/gii/generators/model/Generator.php b/extensions/gii/generators/model/Generator.php
index c01addc..c6d2b09 100644
--- a/extensions/gii/generators/model/Generator.php
+++ b/extensions/gii/generators/model/Generator.php
@@ -575,7 +575,7 @@ class Generator extends \yii\gii\Generator
      */
     protected function getDbConnection()
     {
-        return Yii::$app->{$this->db};
+        return Yii::$app->get($this->db, false);
     }
 
     /**