Because MV is crappy for anything complex
Thanks for this example. I'm trying - and failing - to extend it to work with multiple models and datasources. For instance, Users accessible from a UserDataSource and UserGroups accessible from a UserGroupDataSource. Help appreciated.
I ran into the same problem and found this post https://developer.apple.com/forums/thread/759634
I've updated the initializer to take a ModelContainer and add all needed Models to it.
```Swift
init(container: ModelContainer) {
self.container = container
}
```
let schema = Schema([Model1.self, Model2.self])
let modelConfiguration = ModelConfiguration(schema: schema)
let container = try ModelContainer(for: Model1.self, Model2.self, configurations: modelConfiguration)
self.model1DB = Model1Database(container: container)
self.model2DB = Model2Database(container: container)
Thanks for this example. I'm trying - and failing - to extend it to work with multiple models and datasources. For instance, Users accessible from a UserDataSource and UserGroups accessible from a UserGroupDataSource. Help appreciated.
I ran into the same problem and found this post https://developer.apple.com/forums/thread/759634
I've updated the initializer to take a ModelContainer and add all needed Models to it.
```Swift
init(container: ModelContainer) {
self.container = container
}
```
```Swift
let schema = Schema([Model1.self, Model2.self])
let modelConfiguration = ModelConfiguration(schema: schema)
let container = try ModelContainer(for: Model1.self, Model2.self, configurations: modelConfiguration)
self.model1DB = Model1Database(container: container)
self.model2DB = Model2Database(container: container)
```