Something wrong with SwiftData

I have made the following code to basically play around with haptics:

LibraryView.swift

import SwiftUI import SwiftData

struct LibraryView: View {

@Environment(\.modelContext) var modelContext
@Query/*(sort: \CustomHaptic.dateMade)*/ var customHapticArray: [CustomHaptic]
@Query/*(sort: \DefaultHaptic.dateMade)*/ var defaultHapticArray: [DefaultHaptic]

@State private var showingAddCustomHaptic = false
@State private var showingAddDefaultHaptic = false

var body: some View {
    NavigationStack {
        VStack {
            List {
                ForEach(customHapticArray) { customHaptic in
                    HStack {
                        VStack {
                            Text("\(customHaptic.sharpness)")
                            Text("")
                            Text("\(customHaptic.intensity)")
                        }

                        Spacer()

                        VStack {
                            Text("\(customHaptic.repeats)")
                        }
                    }
                }
            }
        }
        .sheet(isPresented: $showingAddCustomHaptic, content: {
            NewCustomHaptic()
        })
        .toolbar {
            Button("New Custom Haptic", systemImage: "plus") {

                showingAddCustomHaptic = true
            }
        }
        .navigationTitle("Haptikiser")
    }
}

} And NewCustomHaptic.swift, which is a sheet to add a new class CustomHaptic:

@Model class CustomHaptic: Identifiable {

var id = UUID()

var dateMade = Date.now

var repeats: Int

var sharpness: Float
var intensity: Float

init(repeats: Int, sharpness: Float, intensity: Float) {
    self.repeats = repeats
    self.sharpness = sharpness
    self.intensity = intensity
}

} and

import SwiftUI import SwiftData

struct NewCustomHaptic: View {

@Environment(\.dismiss) var dismiss

@Environment(\.modelContext) var modelContext
@Query(sort: \CustomHaptic.dateMade) var customHapticArray: [CustomHaptic]

@State var sharpness: Float = 1
@State var intensity: Float = 1
@State var repeats: Int = 3

let array0to1: [Float] = [0.2, 0.4, 0.6, 0.8, 1.0]

var body: some View {
    VStack {
        Form {
            Section("Sharpness") {
                Picker(selection: $sharpness, label: Label("Sharpness", systemImage: "bolt.horizontal")) {
                    ForEach(array0to1, id: \.self) { i in
                        Text("\(Int(i * 10))")

                    }

                }

                .pickerStyle(.segmented)

            }

            Section("Intensity") {
                Picker(selection: $intensity, label: Label("Intensity", systemImage: "42.circle")) {
                    ForEach(array0to1, id: \.self) { i in
                        Text("\(Int(i * 10))")

                    }

                }
                .pickerStyle(.segmented)

            }

            Section("Repeats") {
                Stepper(value: $repeats, in: 1...10) {
                    Label("\(repeats)", systemImage: "repeat")
                }
            }
        }

        Button("Done") {

            let newCustomHaptic = CustomHaptic(repeats: repeats, sharpness: sharpness, intensity: intensity)
            modelContext.insert(newCustomHaptic)

            dismiss()
        }
        .buttonStyle(.borderedProminent)
        .font(.title)

        Spacer()
    }

}

} every single time i run it, i get " Query encountered an error: Error Domain=NSCocoaErrorDomain Code=256 "The file “default.store” couldn’t be opened." " in the console.

And when I press done on the sheet, i get the same error.

Thank you for helping

Something wrong with SwiftData
 
 
Q