---
title: "insert(_:)"
framework: swiftdata
role: symbol
role_heading: Instance Method
path: "swiftdata/modelcontext/insert(_:)"
---

# insert(_:)

Registers the specified model with the context so it can include the model in the next save operation.

## Declaration

```swift
func insert<T>(_ model: T) where T : PersistentModel
```

## Parameters

- `model`: The model to include in the next save operation.

## Discussion

Discussion A model is given a temporary persistent identifier until the first time a context saves it, after which that context assigns a permanent identifier. If you call rollback() after inserting a model but before the next save operation, the context discards that model.

## See Also

### Inserting models

- [insertedModelsArray](swiftdata/modelcontext/insertedmodelsarray.md)
