How to create a ModelContainer with [PersistentModel] and SchemaMigrationPlan

I can't find the method to create ModelContainer that appears in the video at 8: 52.

The code in the video is as follows:

let container = ModelContainer(
    for: Trip.self,
    migrationPlan: SampleTripsMigrationPlan.self
)

This method doesn't seem to exist in Xcode15.

I found other method to create ModelContainer using Schema and Schema MigrationPlan in Xcode15.

public convenience init(for givenSchema: Schema, migrationPlan: (SchemaMigrationPlan.Type)? = nil, _ configurations: ModelConfiguration...) throws

And I tried to create a Schema to use this method, like this:

let container = try! ModelContainer(for: .init([Person.self]), migrationPlan: MigrationPlan.self)

But an error occurred during runtime

SwiftData/ModelContext.swift:177: Fatal error: Container does not have any data stores

How to create a ModelContainer with [PersistentModel] and SchemaMigrationPlan ?


Xcode Version: 15.0 beta (15A5160n)

MacOS: 13.3.1 (a) (22E772610a)

Ok, I know.

Maybe I should create a Model Container through Schema and SchemaMigrationPlan.

But why does the app generate an error "cannot open file" after running?

And SchemaMigrationPlan doesn't working, I haven't received stage's willMigrate and didMigrate callbacks

How to create a ModelContainer with [PersistentModel] and SchemaMigrationPlan
 
 
Q