I think this issue could be caused by ModelContext AutoSave, it only actually saves the data after the data have been inserted for about 30 seconds, during this delay time, the modelContext.delete() function doesn't work.
Post
Replies
Boosts
Views
Activity
Because I found this could be an issue of iOS 17.2, so I created another thread for this issue w/ some clearer info:
https://developer.apple.com/forums/thread/740997
Not sure why, but after upgrading to macOS 12.6, now I can deploy the app to iPad with iOS 15.7 by Xcode 14 which does not support iOS 15.7 (previously it's impossible with old macOS version 12.5) 😅