EOEntity
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
Note that if an entity has no enterprise object class name, the database-level objects use EOGenericRecord.
This code excerpt gives an example of creating an EOEntity and adding it to an EOModel:
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];