Name clashes with SwiftData classes

I have a shopping list app and the data model is very simple, just 5 entities. These have names List, Product, Item, Section and Data. For CoreData I was able to use the auto-generated classes and gave my own names for the classes (prefixing my entity names with CD - e.g CDList)

However with SwiftData I don't have that capability. My @Model classes are named List, Data etc and obviously these clash with the standard Swift/SwiftUI classes. Even the much quoted example app has the same issue a task todo list with an entity named Task, which would clash with Swift's own Task class.

Is the correct/only approach that I don't use the @Model macro but roll my own SwiftData classes - e.g inline the macros, or is there a way I can give the @Model classes my own name (e.g SDList, and leave the CoreData entity names as they are). I don't really want to rename my entities if at all avoidable.

Never use names already defined in the frameworks. Always use original names for your types.

You could use an enum to create a namespace for your models

enum App {
    @Model
    final class List {
        ...
    }
}

struct ContentView: View {
    @Query var elements: [App.List]
}
Name clashes with SwiftData classes
 
 
Q