SwiftData doesn't synthesize Codable conformance for you, but adding it by hand follows the usual pattern. If your model has relationships, those need to be Codable too: www.hackingwithswift.com/quick-start/...
Learn Swift coding for iOS with these free tutorials