Table 'tbl_user' does not exist

Newbie Alert

I get the error Table ‘tbl_user’ does not exist in Gii Model Generator. This error is gone if I manually create the table in my database with some fields. Is it supposed to work that way? I have worked on python’s Django framework before. There we have to just write model class definition with all the fields inside, and just run syncdb on terminal. The sql tables, fk relationships etc are all created and handled on the fly. I was expecting the same in yii, that the table will be created automatically. What am I missing here?

Appears like I am not the only one getting this error. I consulted this thread http://www.yiiframework.com/forum/index.php?/topic/19113-model-generator-fails-on-creating-table-tbl-user/ . But it just mentions to tweak db settings in main.php, which are perfectly valid in my case.

I am using MySQL and my config settings are:




		'db'=>array(

			'connectionString' => 'mysql:host=127.0.0.1;dbname=yii_firstapp',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'root',

			'charset' => 'utf8',

		),



Yii doesn’t create tables automatically, but there is a database schema under protected/data directory (for mysql use schema.mysql.sql). Gii is supposed to generate models/crud for existing databases.

I know this is an old thread, but encountered this issue. The resolution was to simply log out of the application! I needed to generate a model for an secondary database when I temporarily switched databases and hit this issue.