---
title: mainContext
framework: swiftdata
role: symbol
role_heading: Instance Property
path: swiftdata/modelcontainer/maincontext
---

# mainContext

A model context that’s bound to app’s main actor.

## Declaration

```swift
@MainActor var mainContext: ModelContext { get }
```

## Mentioned in

Reverting data changes using the undo manager
