How to completely reset SwiftData?

Is it possible to reset SwiftData to a state identical to that of a newly installed app?

I have experienced some migration issues where, when I add a new model, I need to reinstall the entire application for the ModelContainer creation to work.

Deleting all existing models does not seem to make any difference.

A potential solution I currently have, which appears to work but feels quite hacky, is as follows:

let _ = try! ModelContainer()
modelContainer = try! ModelContainer(for: Student.self, ...)

This seems to force out this error CoreData: error: Error: Persistent History (66) has to be truncated due to the following entities being removed: (...) which seems to reset SwiftData.

Any other suggestions?

Is this for a released app or only local in Xcode?

How do I delete my own reply lol?

How to completely reset SwiftData?
 
 
Q