# TypeORM to MikroORM Migration {#typeorm-to-mikroorm-migration}


Guide for migrating custom entities from TypeORM-only to dual MultiORM support.


## Overview {#overview}


Ever Gauzy supports both TypeORM and MikroORM simultaneously via Multi-ORM decorators. When creating or modifying entities, use the `@MultiORM*` decorators to ensure compatibility with both ORMs.


## Decorator Mapping {#decorator-mapping}


| TypeORM Decorator | MultiORM Equivalent     |
| ----------------- | ----------------------- |
| `@Entity()`       | `@MultiORMEntity()`     |
| `@Column()`       | `@MultiORMColumn()`     |
| `@ManyToOne()`    | `@MultiORMManyToOne()`  |
| `@OneToMany()`    | `@MultiORMOneToMany()`  |
| `@ManyToMany()`   | `@MultiORMManyToMany()` |
| `@JoinTable()`    | `@MultiORMJoinTable()`  |
| `@Index()`        | `@MultiORMIndex()`      |


## Example Migration {#example-migration}



### Before (TypeORM only) {#before-typeorm-only}


```typescript
import { Entity, Column, ManyToOne } from "typeorm";

@Entity("my_entity")
export class MyEntity extends TenantOrganizationBaseEntity {
  @Column()
  name: string;

  @ManyToOne(() => User, { nullable: true })
  user?: User;
}
```


### After (MultiORM) {#after-multiorm}


```typescript
import { MultiORMEntity, MultiORMColumn, MultiORMManyToOne } from "@gauzy/core";

@MultiORMEntity("my_entity")
export class MyEntity extends TenantOrganizationBaseEntity {
  @MultiORMColumn()
  name: string;

  @MultiORMManyToOne(() => User, { nullable: true })
  user?: User;
}
```


## Repository Migration {#repository-migration}



### Before {#before}


```typescript
import { Repository } from "typeorm";

@Injectable()
export class MyService {
  constructor(
    @InjectRepository(MyEntity)
    private repository: Repository<MyEntity>,
  ) {}
}
```


### After {#after}


```typescript
import { TypeOrmMyEntityRepository } from "./repository/type-orm-my-entity.repository";
import { MikroOrmMyEntityRepository } from "./repository/mikro-orm-my-entity.repository";

@Injectable()
export class MyService extends TenantAwareCrudService<MyEntity> {
  constructor(
    typeOrmRepo: TypeOrmMyEntityRepository,
    mikroOrmRepo: MikroOrmMyEntityRepository,
  ) {
    super(typeOrmRepo, mikroOrmRepo);
  }
}
```


## Common Pitfalls {#common-pitfalls}


1. **MikroORM stricter validation** — MikroORM 6.x validates metadata more strictly
2. **Relation decorators** — use conditional decorators for ORM-specific relations
3. **Entity discovery** — ensure entities are registered in both ORMs


## Related Pages {#related-pages}


- [Multi-ORM Deep Dive](https://sourcey-gauzy.pages.dev/advanced/multi-orm-deep-dive/index.md) — ORM architecture
- [Entity Inheritance](https://sourcey-gauzy.pages.dev/architecture/entity-inheritance/index.md) — base entities
- [Custom Entity Fields](https://sourcey-gauzy.pages.dev/advanced/custom-entity-fields/index.md) — custom fields
