programmatically – Magento 2: Error while create category programmtically: Call to undefined method MagentoCatalogModelResourceModelCategoryFlat::getEntityTable()

I am creating a category programmatically in magento 2 in controller, but I am getting error Call to undefined method MagentoCatalogModelResourceModelCategoryFlat::getEntityTable()
I have also run indexing to solve a problem but no luck.

Note: I have enabled flat categories in configuration.

$objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $url = MagentoFrameworkAppObjectManager::getInstance();
            $storeManager = $url->get('MagentoStoreModelStoreManagerInterface');
            //$state = $objectManager->get('MagentoFrameworkAppState');
            //$state->setAreaCode('frontend');
            /// Get Website ID
            $websiteId = $storeManager->getWebsite()->getWebsiteId();
            echo 'websiteId: '.$websiteId." ";
    
            /// Get Store ID
            $store = $storeManager->getStore();
            $storeId = $store->getStoreId();
            echo 'storeId: '.$storeId." ";
    
            /// Get Root Category ID
            $rootNodeId = $store->getRootCategoryId();
            echo 'rootNodeId: '.$rootNodeId." ";
            /// Get Root Category
            $rootCat = $objectManager->get('MagentoCatalogModelCategory');
            $cat_info = $rootCat->load($rootNodeId);
    
            $categorys=array('Levis','Wranglers'); // Category Names
            foreach($categorys as $cat)
            {
    
            $name=ucfirst($cat);
            $url=strtolower($cat);
            $cleanurl = trim(preg_replace('/ +/', '', preg_replace('/(^A-Za-z0-9 )/', '', urldecode(html_entity_decode(strip_tags($url))))));
            $categoryFactory=$objectManager->get('MagentoCatalogModelCategoryFactory');
            /// Add a new sub category under root category
            $categoryTmp = $categoryFactory->create();
            $categoryTmp->setName($name);
            $categoryTmp->setIsActive(true);
            $categoryTmp->setUrlKey($cleanurl);
            $categoryTmp->setData('description', 'description');
            $categoryTmp->setParentId($rootCat->getId());
            $categoryTmp->setStoreId($storeId);
            $categoryTmp->setPath($rootCat->getPath());
            $categoryTmp->save();
            }