@Volker Runkel - This isn't something I would recommend going to production with, and I doubt it's a complete solution (I am still seeing SQLite errors in the debug console), but in order to continue development I have come up with the following work-around (at least until I hear back from DTS):
@main
struct TestDocumentAppApp: App {
var body: some Scene {
DocumentGroup(editing: .itemDocument, migrationPlan: TestDocumentAppMigrationPlan.self) {
IntermediarySceneView {
ContentView()
}
}
}
}
struct IntermediarySceneView<Content: View>: View {
@Environment(\.modelContext) private var originalModelContext
let content: Content
var body: some View {
content.environment(\.modelContext, originalModelContext.container.mainContext)
}
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
}
Basically, all this is doing is overriding the modelContext variable by traversing back to the container and grabbing the mainContext (AFAIK that is what it should be). It seems to prevent crashes in my limited testing, but there is a good chance there are issues elsewhere (I'm not sure where else the incorrect context may still be in use), so YMMV.