Yii2 console relation comes empty

I have an issue with a relation on a model thru console.
The relation comes empty thru console but when running thru web controller it comes with the related rows.
Both controllers executes the same module function. Do you know what is happening?

Here is the code:

class CContractController extends Controller
    public function actionUpdate()
        $module= \Yii::$app->getModule('contrato');

            return ExitCode::OK;
        } else {
            return ExitCode::DATAERR;

class AlarmdotcomModule extends \yii\base\Module
    public function UpdateList(){
        $list= Sites::find()->with('contrato')->all();
        echo "without:".count($list)."-";
        foreach ($list as $site){ 
        echo "updated:".$ii;

class Sites extends \yii\db\ActiveRecord
    /** relation
     * @return \yii\db\ActiveQuery
    public function getContrato()
        return $this->hasOne(Contratos::className(), ['id' => 'contrato_id'])->alias('contrato');

Should not matter if it’s console or not. Have you checked what’s the difference in the AR object?

Hi Alexander
Sorry found the issue, I had the problem on ContratosSearch
It was filtering the records based on the user.

so we can close this.