private static function createEntityManagerWithConnection($connection, Configuration $config, EventManager $evm = null)
    {
        if ($connection instanceof Connection) {
            try {
                return EntityManager::create($connection, $config, $evm);
            } catch (\Exception $e) {
                throw new InvalidArgumentException(
                    'Enable to create new EntityManager with provided Connection',
                    InvalidArgumentException::INVALID_ARGUMENT,
                    $e
                );
            }
        }

        throw new InvalidArgumentException('Invalid Connection provided', InvalidArgumentException::INVALID_ARGUMENT);
    }