This guide covers migrating Ember Data models from the legacy syntax to the modern one.
Useful docs:
Table of Contents
- Overview
- Basic Migration Pattern
- Attributes Migration
- Relationships Migration
- Computed Properties Migration
- Testing Migrated Models
- Complete Example
- Best Practices
Overview
The migration involves converting from:
- DS.Model.extend({...})→- export default class ModelName extends Model
- attr()→- @attr()decorator
- belongsTo()→- @belongsTo()decorator
- hasMany()→- @hasMany()decorator
Basic Migration Pattern
Before (Legacy Syntax)

After (Modern Syntax)

Attributes Migration
Simple Attributes

Attributes with Default Values

Relationships Migration
BelongsTo Relationships

HasMany Relationships

Computed Properties Migration

Testing Migrated Models
Basic Test Setup

Testing Attributes

Testing Computed Properties

Complete Example
Before (Legacy Model)

After (Modern Model)

