2 Comments

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.

Expand full comment
Aug 6·edited Aug 6

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)

```

Expand full comment