---
title: modelContext
framework: swiftdata
role: symbol
role_heading: Instance Property
path: swiftdata/query/modelcontext
---

# modelContext

Current model context Query interacts with.

## Declaration

```swift
@MainActor @preconcurrency var modelContext: ModelContext { get }
```

## Discussion

Discussion Access this value from Query property wrapper’s stored property: struct RecipeList: View {     @Query var recipes: [Recipe]     var body: some View {         ChangesIndicator(             hasChanges: _recipes.modelContext.hasChanges)     } } Only access this property within of a view’s body property, otherwise its value may be invalid.

## See Also

### Getting query configuration

- [fetchError](swiftdata/query/fetcherror.md)
