![](../../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../../images/next.gif)
Creating an Entity
An EOEntity requires at least the following to be usable:
- A name
- The name of a table in the database (the external name)
- The name of an enterprise object class
- A set of attributes to be used as the primary key
EOModel *myModel; /* Assume this exists. */
NSArray *keyAttributes; /* Assume this exists. */
EOEntity *employeeEntity;
BOOL result;
employeeEntity = [[[EOEntity alloc] init] autorelease];
[employeeEntity setName:@"employee"];
[employeeEntity setExternalName:@"EMPLOYEE"];
[employeeEntity setClassName:@"Employee"];
/* Create at least the primary key attributes. */
result = [employeeEntity setPrimaryKeyAttributes:keyAttributes];
/* Add the entity to the model. */
[myModel addEntity:employeeEntity];
![](../../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../../images/next.gif)
Copyright © 1998, Apple Computer, Inc. All rights reserved.