title: Core data: Failed to load model
body: <p>I am new to core data.</p>
  
  <p><strong>What I am trying to DO:</strong> I am trying to create a cocoatouch framework that has an app to add employee details and display them in a table view. So that i can add this framework to my main project to work independently.</p>
  
  <p><strong>Issues I face:</strong> The frame work builds without any error. I have added the core data stack from swift 3 to the framework. But when i run the main project, the moment the framework loads the log displays "Failed to load model named Simple framework", "fetch failed" and "employee must have a valid entity description". The code that I have used in the framework is as shown below : </p>
  
  <pre><code>public class CoreDataStack {
      public static let sharedInstance = CoreDataStack()
  
      lazy var persistentContainer: NSPersistentContainer = {
          let container = NSPersistentContainer(name: "SimpleFramework")
          container.loadPersistentStores(completionHandler: { (storeDescription, error) in
              if let error = error {
                  fatalError("Unresolved error \(error), \(error)")
              }
          })
          return container
      }()
  
      public func saveContext() {
          let context = persistentContainer.viewContext
          if context.hasChanges {
              do {
                  try context.save()
              } catch let error as NSError {
                  fatalError("Unresolved error \(error), \(error.userInfo)")
              }
          }
      }
  }
  
  @IBAction func addEmployee(_ sender: Any) {
  
      //To save the data
      let context = CoreDataStack.sharedInstance.persistentContainer.viewContext
      let employee = Employee(context: context)
      employee.employeeName = nameTextField.text
      employee.employeeAge = Int16(ageTextField.text!)!
      employee.hasVehicle = hasVehicle.isOn
      CoreDataStack.sharedInstance.saveContext()
      navigationController!.popViewController(animated: true)
  }
  
  @IBAction func addEmployee(_ sender: Any) {
  
      //To save the data
      let context = CoreDataStack.sharedInstance.persistentContainer.viewContext
      let employee = Employee(context: context)
      employee.employeeName = nameTextField.text
      employee.employeeAge = Int16(ageTextField.text!)!
      employee.hasVehicle = hasVehicle.isOn
      CoreDataStack.sharedInstance.saveContext()
      navigationController!.popViewController(animated: true)
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/V23cx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V23cx.png" alt="This is a screenshot of the console log."></a></p>