Fixed bug where the wrong type was used when serializing entityMetadata