BXDatabaseContext is responsible for creating all new objects in the BaseTen system. For the whole apparatus to work, the context needs to know about your objects: that's why you can't just go and instantiate BXDatabaseObjects on your own. To create an object, you usually only need one thing: the entity description for the table you want the object inserted to.
BXEntityDescription* entity = [ctx entityForTable:@"test" inSchema:@"public"]; NSError* error = nil; BXDatabaseObject* object = [ctx createObjectForEntity:entity withFieldValues:nil error:&error];
By default, the context will go ahead and create your object with the default column values you have set in your database schema. But if you are using a natural (as opposed to a synthetic) primary key, it is likely that the database cannot generate a reasonable primary key on its own. If that's the case, creating a new object will fail with an error unless you fill the withFieldValues: parameter with an NSDictionary of the field values that make up your primary key.
The class of the new object depends on the entity description. By default, the class will be a BXDatabaseObject, but you can also use a subclass of your own. To do that, you alter the entity description:
[entity setDatabaseObjectClass:[Test class]];
After that, all objects created or fetched with that entity description will be of the subclass you specified (here, the "Test" class).
