Same issue, I have something like
var body: some View {
List(cars) { car in
NavigationLink(car.name, destination: CarDetailView(car: car))
}
.onAppear(perform: {
let newCar = Car(name: "Fordyota", date: [Date(date: Date())])
modelContext.insert(newCar)
})
}
where name is @Attribute(.unique)