title: overcome MustBeEntityError: Cannot save, given value must be an entity, instead "undefined" is given
body: <p>I would like to specify a one to one relationship for User and Profile. User owns the relationship, we can say that a user has a profile. But the problem is when I run the code I get the error message:</p>
  <pre><code>{ name: 'Greg', password: '123', email: 'greg@here.com' }
  MustBeEntityError: Cannot save, given value must be an entity, instead &quot;undefined&quot; is given.
  </code></pre>
  <p>It is expecting user.profile to be defined in postman, but the problem is that I'm building a SPA with React at the frontend  so at the time when the user signs up, the profile does not even exists yet. To solve this issue , I thought about  giving  a default value for profile when I call the route which creates the user and then later create the profile and update the profile for that user through another route.</p>
  <p>this is my User.ts:</p>
  <pre><code>@Entity(&quot;User&quot;)
  export class User extends BaseEntity {
    @Column(&quot;number&quot;)
    @PrimaryGeneratedColumn()
    id: number;
  
    @Column(&quot;text&quot;)
    name: string;
  
    @Column(&quot;text&quot;)
    password: string;
  
    @Column(&quot;text&quot;)
    email: string;
  
    // https://stackoverflow.com/questions/62460079/typeorm-foreign-key-not-showing-on-a- 
    find-call
    @Column(&quot;number&quot;, { default: -1, name: &quot;profileId&quot; })
    profileId: number;
  
    @OneToOne(() =&gt; Profile, { cascade: true })
    @JoinColumn({ name: &quot;profileId&quot; })
    profile: Profile;
  
  }
  
  and this is my Profile.ts:
  
  @Entity(&quot;Profile&quot;)
  export class Profile extends BaseEntity {
    @Column(&quot;number&quot;)
    @PrimaryGeneratedColumn()
    id: number;
  
    @Column(&quot;text&quot;, { nullable: true })
    gender: string;
  
    @Column(&quot;text&quot;, { nullable: true })
    occupation: string;
  
    @OneToOne(() =&gt; User, (user) =&gt; user.profile) // specify inverse side as a second parameter
    user: User;
  }
  </code></pre>