public function validateMetadata($requestedType, EntityMetadata $metadata, MetadataFactory $mf)
    {
        if ($requestedType !== $metadata->type) {
            throw MetadataException::invalidMetadata($requestedType, 'Metadata type mismatch.');
        }
        $this->validateMetadataType($metadata);

        if (null === $metadata->persistence) {
            throw MetadataException::invalidMetadata($requestedType, 'No persistence metadata was found. All models must use a persistence layer.');
        }

        $this->validateMetadataInheritance($metadata, $mf);
        $this->validateMetadataAttributes($metadata, $mf);
        $this->validateMetadataRelationships($metadata, $mf);
        $this->validateMetadataEmbeds($metadata, $mf);
        return true;
    }