Skip to content
AutoMapper TypeScript
Esc
navigateopen⌘Jpreview

MikroORM strategy

Map MikroORM 6 entities with entity, reference, and collection serialization built into the classes strategy.

@automapper/mikro extends the classes strategy for MikroORM 6.

npm install @automapper/core @automapper/classes @automapper/mikro reflect-metadata
pnpm add @automapper/core @automapper/classes @automapper/mikro reflect-metadata
bun add @automapper/core @automapper/classes @automapper/mikro reflect-metadata
const mapper = createMapper({
  strategyInitializer: mikro(),
});

Use @AutoMap() metadata and register mappings exactly as with classes(). The default preMap recursively serializes MikroORM entities, references, and collections before member mapping begins.

Override strategy behavior when your entity lifecycle needs it:

const mapper = createMapper({
  strategyInitializer: mikro({
    preMap: (source, mapping) => customSerialize(source, mapping),
    destinationConstructor: (_, destinationIdentifier) =>
      entityManager.create(destinationIdentifier, {}),
  }),
});

Supplying preMap replaces MikroORM’s default serialization hook, so the custom implementation is responsible for producing a mappable source shape.

Last updated on July 16, 2026

Was this page helpful?