The main configuration of the file ( main.php ) is as follows: I can connect to the database successfully, but when generating a model from Yii Code Generator it tells me that the table does not exist. Answer Table exists? Gii generates a model based on table. First you need to create a table. If you use console version gii,