There is probably a better way to do this, and actually migrate the old data. But what I've been doing since I have just been working with new apps in simulators so far is this.
In your main app file, add an initializer like this...
import SwiftData
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(for: MyDataType.self)
}
init() {
print(URL.applicationSupportDirectory.path(percentEncoded: false))
}
}
Then, when you run your app, it will print a line that tells you the location where your database files are stored. You can go to that location in finder, and you should find 3 files there. (default.store, default.store-shm, and default.store-wal)
If you delete all 3 of those files, they will automatically regenerate when you run your app again. However, your data will be completely deleted, and you will start with a fresh empty database. But it has allowed me to work around errors like this while I'm still in the beginning stages of making my app.