首页 > 解决方案 > Gii 模型生成器不会让我创建模型。(抛出表“作者”不存在)

问题描述

我为作者表创建了一个迁移。

public function up()
    {
        $this->createTable('authors', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull()
        ]);
    }

    public function down()
    {
        $this->dropTable('authors');
    }

迁移表后,我想为迁移制作模型。所以尝试使用 gii 创建模型,这就是我得到的。 在此处输入图像描述

表作者已由迁移创建,但 gii 模型生成器仍然显示表“作者”不存在。还有什么我想念的吗?

这是我的 db.php 文件

<?php

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=myFirstYii',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8',

    // Schema cache options (for production environment)
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 60,
    //'schemaCache' => 'cache',
];

标签: yiiyii2gii

解决方案


推荐阅读