title: Mikro-ORM still cascades while persisting even when deactivated
body: <p>I must be doing something wrong with my entity relationships because whenever I try to persist a parent entity with its children, Mikro-ORM keeps trying to persist the children as well, even if cascading has been deactivated for the given properties.</p>
  <p>I have some concerts:</p>
  <pre><code>import { Entity, PrimaryKey, Property, SerializedPrimaryKey, Collection, ManyToMany } from &quot;@mikro-orm/core&quot;;
  import { ObjectId } from 'mongodb';
  import { Artist } from &quot;./artist&quot;;
  
  type Props = {
      readonly _id: ObjectId;
      readonly artists?: Collection&lt;Artist&gt;;
  }
  
  @Entity()
  export class Concert {
      constructor(private props: Props) { Object.assign(this, props) }
  
      /* Private variables */
      @PrimaryKey()
      readonly _id!: ObjectId;
  
      @SerializedPrimaryKey()
      id!: string; // won't be saved in the database
  
      @ManyToMany({ entity: () =&gt; Artist, mappedBy: 'concerts', cascade: [] }) // cascading should be deactivated
      public readonly artists = new Collection&lt;Artist&gt;(this);
  }
  </code></pre>
  <p>and some artists :</p>
  <pre><code>import { Entity, PrimaryKey, Property, SerializedPrimaryKey, Collection, ManyToMany, Cascade, OneToMany } from &quot;@mikro-orm/core&quot;;
  import { ObjectId } from 'mongodb';
  import { Concert } from &quot;./concert&quot;;
  import { User } from &quot;./user&quot;;
  
  type Props = {
      readonly _id: ObjectId;
      readonly concerts?: Collection&lt;Concert&gt;;
      readonly name: string;
  }
  
  @Entity()
  export class Artist {
      constructor(private props: Props) { Object.assign(this, props) }
  
      /* Private variables */
      @PrimaryKey()
      readonly _id!: ObjectId;
  
      @SerializedPrimaryKey()
      id!: string; // won't be saved in the database
  
      @ManyToMany({ entity: () =&gt; Concert, mappedBy: 'artists', cascade: [], owner: true }) // cascading should be deactivated
      public readonly concerts = new Collection&lt;Concert&gt;(this);
  
      @Property()
      public readonly name!: string;
  }
  </code></pre>
  <p>I already have an artist saved in my mongodb database, under the <code>artist</code> collection with the example ObjectId  <code>_id : ObjectId(&quot;a&quot;)</code>.</p>
  <p>When trying to persist like so :</p>
  <pre><code>const concert = new Concert({ _id: new ObjectId() });
  
  concert.artists.add(new Artist({ &quot;_id&quot;: new ObjectId(&quot;a&quot;), &quot;name&quot;: &quot;&quot; })) 
  
  await concertRepository.persistAndFlush(concert)
  </code></pre>
  <p>I get the following message:</p>
  <pre><code>UniqueConstraintViolationException: E11000 duplicate key error collection: db.artist index: _id_ dup key: { _id: ObjectId('a') }
  </code></pre>
  <p>Does anyone know what I'm doing wrong?</p>