Code Generator

You'll quickly find many of the steps when building your module's becomes repetitive. This is where the code generator shines. The code generator is a .NET global tool you use with the Terminal.

Installing

Execute the following command:

dotnet tool install "Kit.CodeGenerator" -g --add-source \\dc\project\400000\KIT\Packages

Updating

Execute the following command:

dotnet tool update "Kit.CodeGenerator" -g --add-source \\dc\project\400000\KIT\Packages

Using the Code Generator

First open the Terminal and change the working path to the module root, for example:

cd src/DemoShop.Shop

Note: Although Windows is case-insensitive, it is important that the name of the folder in the path is in the correct case as it is used to work out the name of the module.

Now you just have to execute the appropriate command. See below for some examples:

Examples

Existing model - list relationships assumed to be ManyToOne and meta data not supported:

kit-codegenerator all Product -a Shop -l -s -d -ne -v

New model (with a property which has a maximum length):

kit-codegenerator all Product -n -a Shop -l -s -d -ne -v -p Name:string:MaximumLength=100

New model (inherited from another model):

kit-codegenerator all Product -n -a Shop -l -s -d -ne -v -p Sku:string?:MaximumLength=100 -b ContentItem -bp Name:string:MaximumLength=100

New model (with composite id):

kit-codegenerator all ProductSite -n -a Shop -l -s -d -ne -v -p Name:string:MaximumLength=100 -i ProductSiteIdentifier -ip Product:Product:ManyToOne -ip Site:Site:ManyToOne

New model (enum):

kit-codegenerator all ContentItemStatus -n -a Shop -e -en New -en Authorised -en Deleted

New model (with an enum property):

kit-codegenerator all ContentItem -n -a Shop -l -s -d -ne -v -p Name:string:MaximumLength=100 -p Status:ContentItemStatus:Enum

New model (with a many-to-many collection property):

kit-codegenerator all Product -n -a Shop -l -s -d -ne -v -p Categories:IList<ProductCategory>:ManyToMany

New model (full example):

kit-codegenerator all Product -n -a Shop -l -s -d -ne -v -p Name:string:MaximumLength=100 -p Sku:string?:MaximumLength=20 -p Head:IHead -p Body:IBody -p DateAdded:DateTimeOffset -p DateUpdated:DateTimeOffset? -p Image:string?:MaximumLength=100 -p Brand:Brand:ManyToOne -p Flag:ProductFlag?:ManyToOne -p Prices:IList<ProductPrice>:OneToMany -p Categories:IList<ProductCategory>:ManyToMany