Relational query get error "Getting unknown property" I built up a plugin and inside the plugin I created the relation between Entry and Section using ActiveRecord, like below:

In SectionRecord :

class SectionRecord extends ActiveRecord
{
    public static function tableName()
    {
        return '{{sections}}';
    }

    public function getEntries()
    {
        return $this-&gt;hasMany(EntryRecord::className(),['id' =&gt; 'sectionId']);
    }
}


In EntryRecord file:

class EntryRecord extends ActiveRecord
{
    public static function tableName()
    {
        return '{{entries}}';
    }

    public function getSection()
    {
        return $this-&gt;hasOne(SectionRecord::className(),['sectionId' =&gt; 'id']);
    }
}


At last in controller:

$hub = SectionRecord::findOne(['handle'=&gt;'hub']);
dd($hub-&gt;entries);


I tried to get section which is working, but when I wanna fetch entries under that section, showed me an error:

Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: raintestplugin\test\records\SectionRecord::sectionId
Because the property sectionId does not exist in the sections table. All models in Craft have the property id as their primary key not - for example - sectionId