     /** The managed object context used for caching. */
     public let managedObjectContext: NSManagedObjectContext
     
+    /** A convenience variable for the managed object model. */
+    public let managedObjectModel: NSManagedObjectModel
+    
     /** The name of a for the date attribute that can be optionally added at runtime for cache validation. */
     public let dateCachedAttributeName: String?
     

            self.prettyPrintJSON = prettyPrintJSON
            self.resourceIDAttributeName = resourceIDAttributeName
            self.dateCachedAttributeName = dateCachedAttributeName
            
            // setup managed object contexts
            self.managedObjectContext = NSManagedObjectContext(concurrencyType: managedObjectContextConcurrencyType)
            self.managedObjectContext.undoManager = nil
            self.managedObjectContext.persistentStoreCoordinator = persistentStoreCoordinator
            self.model = persistentStoreCoordinator.managedObjectModel
            
            self.privateQueueManagedObjectContext.undoManager = nil
            self.privateQueueManagedObjectContext.persistentStoreCoordinator = persistentStoreCoordinator
            
            // listen for notifications (for merging changes)
            NSNotificationCenter.defaultCenter().addObserver(self, selector: "mergeChangesFromContextDidSaveNotification:", name: NSManagedObjectContextDidSaveNotification, object: self.privateQueueManagedObjectContext)
            
            // edit model
            
            if self.dateCachedAttributeName != nil {
                
                self.model.addDateCachedAttribute(dateCachedAttributeName!)
            }
            
            self.model.markAllPropertiesAsOptional()
            
            self.model.addResourceIDAttribute(resourceIDAttributeName)
    }
    
    // MARK: - Requests

    
    public func fetchEntity(name: String, resourceID: UInt, URLSession: NSURLSession = NSURLSession.sharedSession(), completionBlock: ((error: NSError?, managedObject: NSManagedObject?) -> Void)) -> NSURLSessionDataTask {
        
        let entity = self.managedObjectModel.entitiesByName[name]! as NSEntityDescription
        
        return self.getResource(entity, withID: resourceID, URLSession: URLSession, completionBlock: { (error, jsonObject) -> Void in
            
