refactored entity metadata setting