protected function createInstance(CreateMetaModelEvent $event, $arrData)
    {
        if (!$this->createInstanceViaLegacyFactory($event, $arrData)) {
            $metaModel = new MetaModel($arrData, $this->dispatcher, $this->database);
            $metaModel->setServiceContainer(function () {
                return $this->getServiceContainer();
            }, false);
            $event->setMetaModel($metaModel);
        }

        if ($event->getMetaModel()) {
            $this->instancesByTable[$event->getMetaModelName()]     = $event->getMetaModel();
            $this->instancesById[$event->getMetaModel()->get('id')] = $event->getMetaModel();
        }
    }