Add Entity Property Command

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

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

craftsman add:entity [options] <filepath>

Add Entity Property 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

Add Entity Property Options

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

Add Entity Property Example Commands

craftsman add:prop --entity Vet --name VetName --type string --filter false --sort true
craftsman add:prop -e Vet -n VetName -t string -f false -s true
craftsman add:prop -e Vet -n VetName -t string
craftsman add:prop -e Sale -n Product -t Product -k ProductId
craftsman add:prop -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:prop 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:prop -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.