EzDbCodeGen.Cli 8.0.1

Requires NuGet 5.0.2 or higher.

dotnet tool install --global EzDbCodeGen.Cli --version 8.0.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local EzDbCodeGen.Cli --version 8.0.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=EzDbCodeGen.Cli&version=8.0.1
nuke :add-package EzDbCodeGen.Cli --version 8.0.1

ez-db-codegen-cli

EzDbCodeGen now works as a local tool.
Easy code generation based on a database schema given by EZDbSchema. The template language this application uses is HandleBars.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. This nuget package will dump the published cli package for code generation and a powershell script to run it. The nuget package will dump everything you need for code generation into the project you have selected under the EzDbCodeGen folder.

Prerequisites

  • [Net 8.0+] (https://www.microsoft.com/net/learn/get-started) - You will get everything you need except the sdk! please download the latest version of this before trying to run the powershell script
  • You will need MSSQL with some database installed. If you need a sample database, feel free to look for the World Wide Importers samples.

NOTE: If you have not set your powershell execution remote policy first, you will need to do this as noted in Powershell Execution Policy

  • Open the powershell command prompt in administrator mode and type: Set-ExecutionPolicy RemoteSigned

Using this project:

  1. Navigate to an empty directoy where you want to install this tool at.
  2. Using the command line: dotnet new tool-manifest
  3. Once this has completed:
    dotnet tool install EzDbCodeGen.Cli --interactive
    (or to update: dotnet tool update EzDbCodeGen.Cli --interactive)
  4. You will need a database that you can run the sample templates against. This utility will build the connection string, test it, download the sample files from the nuget library, copy them to the proper location, then perform the code generation was instructed by the templates.
    dotnet ezdbcg

Deployment

This project was design to be hosted and distributed with nuget.com.

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Many thanks to the following projects that have helped in this project

  • EzDBSchema
  • McMaster.Extensions.CommandLineUtils

HandleBar Custom Functions

  • {{ ContextAsJson }} - Will dump the current context as a JSON file on the rendered file, useful for debugging
  • {{ Prefix $p1 }} - Will append a string to the beginning of the string passed through $p1
  • {{ ExtractTableName $p1 }} - Used the extract the table name from a schema.table object name format
  • {{ ExtractSchemaName $p1 }} - Used the extract the schema name from a schema.table object name format
  • {{ ToSingular $p1 }} - Will change $p1 to a singular word
  • {{ Comma }} - Will output a comma
  • {{ ToPlural }} - Will change $p1 to a plural word
  • {{ ToNetType $p1 }} - Assuming that the string is a sql type, it will return the corresponding .net type with a ? if the property is nullable
  • {{ ToCodeFriendly $p1 }} - Will write a string removing code unfriendly characters
  • {{ PropertyNameSuffix $p1 }} - Will output a code friendly string
  • {{ ToJsType }} - Assuming that the string is a sql type, it will return the corresponding javascript type appending "| null" if it is nullable
  • {{ AsFormattedName $p1 }} - Strips ID, UID, or id from $p1
  • {{ ToSnakeCase $p1 }} - Will turn $p1 into snake case
  • {{ ToSingularSnakeCase $p1 }} - Will turn $p1 into snake case singular
  • {{ ToTitleCaseSafeFileName $p1 }} - Will turn $p1 into Title case and safe for a file name (excellent for the <FILE/> clause )
  • {{ ToCsObjectName $p1 }} - Will convert $p1 to a string sutable for C# Code name
  • {{ StringFormat $p1, $p2 }} - Versitile string function that lets you apply 1 or more formatting tasks on $p1, $p2 can cantain one more of 'lower,upper,snake,title,pascal,trim,plural,single,nettype,jstype', performed in order
  • {{ EntityCustomAttribute $p1 }} - Upeer stirng and replacing "US_" to ""
  • {{ IfPropertyExists $p1 }} - Will search the parent context to see of the entity name exists, will only write the code after to {{/IfPropertyExists}} if true
  • {{ isRelationshipCount $p1 $p2 }} - $p1 should be a comparison op >, =, ==, <, !=, <>, $p2 should be the number compared to will only write the code after to {{/isRelationshipCount}} if true
  • {{ isRelationshipTypeOf $p1}} - Should be called when the context is a Relationship or RelaitonshipList, $p1 can = OneToMany, ZeroOrOneToMany, ZeroOrOneToManyOnly, ManyToOne, ManyToZeroOrOne, ManyToZeroOrOneOnly, OneToOne, OneToZeroOrOne, OneToZeroOrOneOnly, ZeroOrOneToOne, ZeroOrOneToOneOnly
  • {{ ToTargetEntityAlias }} - Should be called when the context is a Relationship or RelaitonshipList, will return the Alias of what this entity is related to
  • {{ ToUniqueColumnName $p1 }} - Will attempt to figured out a unique column name if one of the same name exists
  • {{ ifPropertyCustomAttributeCond $p1 $p2 $p3}} - Tests the value of a particular custom attribute of a propery, if true will write code from tag to {{/ifPropertyCustomAttributeCond}} or {{else}}. if false, it will write from {{else}} to {{/ifPropertyCustomAttributeCond}} $p1 = attribute name $p2 = should be a comparison op >, =, ==, <, !=, <> $p3 = value to compare
  • {{ isNotInList $p1 $p2 \[$p3\]...\[$pn\] }} - Will return true if $p1 does not exist in $p2(+), will write from tag isNotInList to {{/isNotInList}} or {{else}} of it doesnt exist, if it does, it will write from {{else}} to {{/isNotInList}}
  • `{{ ifNot $p1 }} - if $p1 is false, this will write all code between this tag and {{/ifNot}} or {{else}}, if true, code to be writtent will be {{else}} to {{/ifNot}}
  • {{ ifCond $p1 \[$p2\] \[$p3\]}} - This function requirs 1 argument or 3 arguments if there is only $p1, then $p1 should be a boolean, otherwise $p1 = 1value to compare $p2 = should be a comparison op >, =, ==, <, !=, <> $p3 = value to if the result of the 3 operators is true, it will write from this tag to {{else}} or {{/ifCond}}, if false then code from {{else}} to {{/ifCond}} will be written
  • {{ IsAuditableOutput $p1 }} - This function will output the contents if $p1 if the entity contains any auditable column (Created. CreatedBy, Updated, UpdatedBy)
  • {{ IsNotAuditableOutput $p1 }} - This function will output the contents if $p1 if the entity DOES NOT contain any auditable column (Created. CreatedBy, Updated, UpdatedBy)

Changes

V 6.0.0 - Added IsNotAuditableOutput template render directive (fixed mispelling)

V 6.0.20 - Added IsNotAuditiableOutput template render directive

V 6.0.19 - Added Data Type Override Added Field Level Type Name and Nullable Overrides

V 6.0.14 - Changed names to be more inclusive

V 6.0.13 - Added tge abiltity to WhiteList/Blacklist based on template and entity file name

V 7.0.1 - Updated to .net 7.0

V 8.0.0 - Updated to .net 8.0

V 8.0.1 - Added Config string fix, update sql client to microsoft.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
8.0.1 176 3/18/2024
8.0.0 145 3/17/2024
7.0.0 365 1/2/2023
6.0.21 491 8/3/2022
6.0.19 454 8/1/2022
6.0.16 508 4/27/2022
6.0.14 451 4/18/2022
6.0.13 469 4/18/2022
6.0.12 450 4/12/2022
6.0.2 333 12/29/2021
6.0.1 354 12/6/2021
6.0.0 6,385 11/23/2021
5.0.10 2,281 6/20/2021

Added .net 8.0 target