Add Entity Property Command

Adds a property to an entity along with all associated DTOs.

Add Entity Command

This command can add a new property onto an entity using just the CLI. No file required!

The Command

craftsman add:entity [options] <filepath>

Arguments

ArgumentRequiredTypeDescription
-e, --entityYesTextName of the entity to add the property. Must match the name of the entity file (e.g. Vet.cs should be Vet)
-n, --nameYesTextName of the property to add
-t, --typeYesTextData type of the property to add
-f, --filterNoBooleanDetermines if the property is filterable
-s, --sortNoBooleanDetermines if the property is sortable
-k, --foreignkeyNoTextWhen adding an object linked by a foreign key, use this field to enter the name of the property that acts as the foreign key

Options

OptionDescription
-h, --helpDisplay help message. No filepath is needed to display the help message.

Example Commands

craftsman add:property --entity Vet --name VetName --type string --filter false --sort true
craftsman add:property -e Vet -n VetName -t string -f false -s true
craftsman add:property -e Vet -n VetName -t string
craftsman add:property -e Sale -n Product -t Product -k ProductId
craftsman add:property -e Vet -n AppointmentDate -t DateTime? -f false -s true

Foreign Keys

Similar to when we're adding an entity with a foreign key in a file, we can add a foreign key property ad hoc using the add:property command. Let's say that we had a Sale entity that has a ProductId property that acts as a foreign key to another Product entity. If we wanted to return the product in our responses, we could add an additional Product property of type Product that links to the primary key of ProductId in our Product entity:

craftsman add:property -e Sale -n Product -t Product -k ProductId

Note that adding foreign keys will currently break the Post and Update integration tests as described in issue #2.