Xcode Entity Modeling Tools for Core Data

The Xcode data modeling tool deals with entities and the relationships between them. You use the tool to define a schema for Core Data. The model ultimately becomes part of your build product and is used by your application at runtime.

The purpose of the Core Data data modeling tool is to create a data model (or schema) for use with the Core Data framework. At runtime, the model is turned into an instance of NSManagedObjectModel with a collection of NSEntityDescription, NSAttributeDescription, NSRelationshipDescription, and NSFetchRequest objects. In some respects this is analogous to the behavior of Interface Builder. With Interface Builder, you graphically create a collection of objects that are then saved in a file (a nib file) and re-created at runtime. As with user interface elements, you can create a model directly in code at runtime; however, it is typically easier to do so graphically using the appropriate tool. Similarly, just as it is possible to modify the user interface after it has been loaded, it is also possible to customize a model after it has been loaded. (A model does have one constraint not shared with a nib file: a model cannot be modified after you have integrated it into the Core Data stack.)

As your application evolves, to accommodate new features you may need to change the schema. Core Data provides an infrastructure for migrating data from one schema (model version) to another—see Core Data Model Versioning and Data Migration Programming Guide. To use this infrastructure, you need to define a versioned model, and mappings between model versions. You create a versioned model using Xcode’s data modeling tool (see Model Versioning) and, if necessary, a mapping model using Xcode Mapping Tool for Core Data.

You should read this document to learn how to use the Xcode entity modeling tool to create a managed object model for a Core Data application. For a task-based example of how to create a data model, see Creating a Managed Object Model with Xcode.

Organization of This Document

This document contains the following sections: