Create a CRUD from a database view using Gii in Yii2
<p>I have generated a Model using gii of a mariadb view, which worked.</p>

<p>Then trying use the gii CRUD generator for the model, I get the error </p>

<pre><code>The table associated with app\models\Future must have primary key(s).
</code></pre>

<p>Which is perfectly understandable as the the view does not have a PK. I found some advice that says to add a primaryKey function to the model so I tried</p>

<pre><code>public function primaryKey()
{
    return 'id';
}
</code></pre>

<p>With id being the column name which is actually the PK in the underlying table, which is part of the view. But this fails with an exception </p>

<pre><code>Cannot make static method yii\db\ActiveRecord::primaryKey() non static in class app\models\Future
</code></pre>

<p>So I tried making the method static but it then throws new exception</p>

<pre><code>Undefined index: i
1. in /home/adrian/projects/mtview/mtview/vendor/yiisoft/yii2-gii/generators/crud/Generator.php at line 509
</code></pre>

<p>Is there a way around this, or is it now impossible to use gii to generate code for Database views?</p>