How to cast a plain json object to typeorm entity

There is a transformer class called PlainObjectToNewEntityTransformer, if I need to invoke its transform function, I have to pass in the EntityMetadata which requires connection, I think casting doesn’t really need connection. The current workaround is to do the following by just assign in constructor, but this won’t preserve the schema since the field keys are often changed.

@Entity('myentities')
export class MyEntity {
  constructor(partial?: Partial<MyEntity>) {
    if (partial) {
      Object.assign(this, partial);
    }
  }
}

const entity = new MyEntity(json);

I am not sure if the casting can be done in a proper way.