 
     func addScore(_ score: Score) {
         let context = persistentContainer.viewContext
-        guard let entity = NSEntityDescription.entity(forEntityName: "Score", in: context)
-            else { fatalError() }
-        let scoreMO = NSManagedObject(entity: entity, insertInto: context)
+        let scoreMO = ScoreMO(context: context)
         scoreMO.setValue(score.date,     forKey: "date")
         scoreMO.setValue(score.numCols,  forKey: "numCols")
         scoreMO.setValue(score.numMines, forKey: "numMines")

            fatalError("Core Data coordinator: failed to execute request with error \(error)")
        }
    }

    deinit {
        persistentContainer = nil
    }
}


class ScoresController {

    private let persistentContainer: NSPersistentContainer

    init(_ persistentContainer: NSPersistentContainer) {
        self.persistentContainer = persistentContainer
