             if $0 is NSAttributeDescription {
                 propertyDescription.defaultValue = String.codingProperty(Property(keyPath: keyPath))
             } else if let relationshipDescription = $0 as? NSRelationshipDescription {
-                propertyDescription.defaultValue = Set([NSManagedObject(entity: relationshipDescription.destinationEntity!.relationshipEntityDescription(keyPath), insertIntoManagedObjectContext: nil)])
+                propertyDescription.defaultValue = NSSet(array: [self.relationshipObject(relationshipDescription, keyPath: keyPath)])
             }
             return propertyDescription
         }
         return entityDescription
+    }
+    
+    func relationshipObject(relationshipDescription: NSRelationshipDescription, keyPath: String) -> NSManagedObject {
+        if let object = self.relationshipObjects[keyPath] {
+            return object
+        }
+        let object = NSManagedObject(entity: relationshipDescription.destinationEntity!.relationshipEntityDescription(keyPath).relationshipEntityDescription(keyPath), insertIntoManagedObjectContext: nil)
+        self.relationshipObjects[keyPath] = object
+        return object
     }
     
     func relationshipEntityDescription(keyPath: String) -> NSEntityDescription {

            return associatedValueOrDefault(&attributeMapKey, defaultValue: [:])
        }
        set {
            objc_setAssociatedObject(self, &attributeMapKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    

    }
}

var relationshipMapKey: Void?

internal extension NSEntityDescription {
    private var relationshipObjects: [String: NSManagedObject] {
        get {
            return associatedValueOrDefault(&relationshipMapKey, defaultValue: [:])
        }
        set {
            objc_setAssociatedObject(self, &relationshipMapKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
    
    func attributeEntityDescription() -> NSEntityDescription {
        let entityDescription = NSEntityDescription()
        entityDescription.name = name! + "Attribute"
