some refactoring on entity generation and add id type