public function validateMetadataInheritance(EntityMetadata $metadata, MetadataFactory $mf)
    {
        if (true === $metadata->isPolymorphic()) {
            foreach ($metadata->ownedTypes as $child) {

                if (false === $this->isEntityTypeValid($child)) {
                    throw MetadataException::invalidMetadata($metadata->type, sprintf('The owned entity type "%s" is invalid based on the configured name format "%s"', $child, $this->config->getEntityFormat()));
                }

                if (false === $mf->metadataExists($child)) {
                    throw MetadataException::invalidMetadata($metadata->type, sprintf('The entity owns a type "%s" that does not exist.', $child));
                }
            }
        }

        if (false === $metadata->isPolymorphic() && true === $metadata->isAbstract()) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity must be polymorphic to be abstract.');
        }

        if (false === $metadata->isChildEntity()) {
            return true;
        }
        if (true === $metadata->isPolymorphic()) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity cannot both be polymorphic and be a child.');
        }
        if ($metadata->extends === $metadata->type) {
            throw MetadataException::invalidMetadata($metadata->type, 'An entity cannot extend itself.');
        }

        if (false === $mf->metadataExists($metadata->extends)) {
            throw MetadataException::invalidMetadata($metadata->type, sprintf('The parent entity type "%s" does not exist.', $metadata->extends));
        }

        $parent = $mf->getMetadataForType($metadata->extends);
        if (false === $parent->isPolymorphic()) {
            throw MetadataException::invalidMetadata($metadata->type, sprintf('Parent classes must be polymorphic. Parent entity "%s" is not polymorphic.', $metadata->extends));
        }
        return true;
    }