public function add(EntityInterface $entity)
    {
        if (!is_a($entity, $this->getEntityClass())) {
            throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
        }
        
        try {
            $em = $this->entityManager->getDoctrineEntityManager();
            $em->persist($entity);
            $em->flush();
            
            return $entity->getId();
        } catch (\Exception $e) {
            throw new Exception('Cannot add the entity "' . $entity . '".', 0, $e);
        }
    }