I am working on installer and upgrade script of Magento 2 In which my **InstallSchema, UpgradeSchema and InstallData** scripts are working but **UpgradeData.php** is not working.

Please check the following code and please help me to trace out the issue.

```
namespace Foggyline\Office\Setup;

use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class UpgradeData implements UpgradeDataInterface
{
    protected $departmentFactory;
    protected $employeeFactory;

    public function __construct(
        \Foggyline\Office\Model\DepartmentFactory $departmentFactory,
        \Foggyline\Office\Model\EmployeeFactory $employeeFactory
    )
    {
        $this->departmentFactory = $departmentFactory;
        $this->employeeFactory = $employeeFactory;
    }

    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        /**************************************/
        //      Start Of Table Department     //
        /**************************************/

        $salesDepartment = $this->departmentFactory->create();
        $salesDepartment->setName('Sales');
        $salesDepartment->save();

        /***************************************************/
        //      End Of Table Department                    //
        //      Start of Employee Entity                   //
        /***************************************************/

        $employee = $this->employeeFactory->create();
        $employee->setDepartmentId($salesDepartment->getId());
        $employee->setEmail('john@sales.loc');
        $employee->setFirstName('John');
        $employee->setLastName('Doe');
        $employee->setServiceYears(3);
        $employee->setDob('1983-03-28');
        $employee->setSalary(3800.00);
        $employee->setVatNumber('GB123456789');
        $employee->setNote('Just some notes about John');
        $employee->save();

        /***************************************************/
        //              End Of Employee Entity             //
        /***************************************************/

        $setup->endSetup();
    }
}

```

**Note:** From above script I am able to make entries in Department table which is a flat table but unable to make entries for employee entity which is an **EAV**.

I get this error.

```
[PDOException] There is no active transaction

PHP Fatal error:  Uncaught exception 'Exception' with message 'User Error: Some transactions have not been committed or rolled back in /vagrant/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3774' in /vagrant/vendor/magento/framework/App/ErrorHandler.php:61

```