Core Data - Error: Persistent History (3) has to be truncated due to the following entities being removed

My app has 2 very simple models which gives me errors whenever I reload the data:

CoreData: error: Error: Persistent History (3) has to be truncated due to the following entities being removed: (
    RecipePersistentModel,
    Ingredient
)
CoreData: warning: Warning: Dropping Indexes for Persistent History
CoreData: warning: Warning: Dropping Transactions prior to 3 for Persistent History
CoreData: warning: Warning: Dropping Changes prior to TransactionID 3 for Persistent History
SQLite error code:1, 'no such table: ZINGREDIENT'
CoreData: error: exception during newFetchedPKsForSourceID: I/O error for database at

These are the models:

final class RecipePersistentModel: Hashable {
    @Attribute(.unique) let id: String
    var title: String
    var desc: String
    @Relationship(deleteRule: .cascade)
    var ingredients: [Ingredient] = []
    
    init(id: String, title: String, desc: String, ingredients: [Ingredient]) {
        self.id = id
        self.title = title
        self.desc = desc
        self.ingredients = ingredients
    }
}
final class Ingredient: Hashable {
    @Attribute(.unique) let id: String
    var name: String
    var count: Int
    
    init(id: String, name: String, count: Int) {
        self.id = id
        self.name = name
        self.count = count
    }
}

The app is on iOS 17 only. I'm having hard time working with SwiftData so far, whats wrong with this code?

I'm having similar issues. You are not alone. Can't find an answer to this. I backed out changes. cleaned my build now get this where I did in prior version.

@yosi199 Did you ever sort this out? I'm having the very same issue and I can't find a single answer and no one is contributing any suggestions even though I've posted on stackoverflow.com as well.

Same issue here, after removing a SwiftData relationship.

Core Data - Error: Persistent History (3) has to be truncated due to the following entities being removed
 
 
Q