modelContainer in SwiftData

Hello, In SwiftUI within Swift Playgrounds on iPad, I get two different results depending on whether I place .modelContainer(for: Valeur.self) immediately after ContentView() or after WindowGroup {....}.

If I place it after WindowGroup {....}, I can neither save to nor query the database in the preview; it only works in read-only mode.

If I place it after ContentView(), it works correctly in both preview and read-write mode.

Which version should I use? Thanks for your feedback.

modelContainer in SwiftData
 
 
Q