GenMac 0.3.0
dotnet tool install --global GenMac --version 0.3.0
dotnet new tool-manifest
dotnet tool install --local GenMac --version 0.3.0
#tool dotnet:?package=GenMac&version=0.3.0
nuke :add-package GenMac --version 0.3.0
GenMac
CLI-driven code generator for ASP.NET Core - Generate models, controllers, views, and complete MVC applications with a single command.
Installation
dotnet tool install --global GenMac
Optional: Add gmc short alias
# Run the setup script
./install-alias.sh
# Or manually add to your shell config (~/.zshrc or ~/.bashrc)
alias gmc='genmac'
Now you can use either genmac or gmc as the command!
Quick Start
# Generate a model
genmac csp.model Product string:name decimal:price int:stock
# Generate model + REST API controller
genmac asp.controller-with-attributes Product \
string:name:required:Name \
decimal:price:required:Price \
int:stock:required:Stock
# Generate complete MVC app with Tailwind CSS
genmac asp.tailwind Task \
title:string:required:Title \
description:text:optional:Description \
dueDate:datetime:optional:"Due Date" \
isCompleted:bool:optional:Completed
Documentation
- Detailed Guide - Complete reference for all features
- Quick Reference - Command syntax cheatsheet
- ASP.NET MVC + Tailwind - MVC application generation
- ASP.NET Controllers - REST API generation
- DbContext & Relationships - Database configuration
- Auto-Generate DbContext - Generate DbContext from Models folder
- Encryption & Security - Security features
Core Commands
1. Generate Model
genmac csp.model <ModelName> [id:<type>] <attributes...>
ID Types: int (default), long, guid
Example:
genmac csp.model Product id:long \
string:name:required:Name \
decimal:price:required:Price:0.00:0:10000 \
int:stock:required:Stock:0 \
bool:isActive:required:"Is Active":true
2. Generate REST API Controller
# Option A: Generate model + controller together
genmac asp.controller-with-attributes <ModelName> <attributes...>
# Option B: Generate controller for existing model
genmac asp.controller <ModelName>
Example:
genmac asp.controller-with-attributes Order \
id:guid \
string:orderNumber:required:"Order Number" \
decimal:total:required:Total \
datetime:orderedAt:required:"Ordered At" \
--route=orders
Generates: Full REST API with CRUD, pagination, search, bulk operations, import/export, soft delete
3. Generate MVC App with Tailwind CSS
genmac asp.tailwind <ModelName> <attributes...> [--project "AppName"]
Example:
genmac asp.tailwind Task \
title:string:required:Title \
description:text:optional:Description \
priority:string:optional:Priority \
dueDate:datetime:optional:"Due Date" \
isCompleted:bool:optional:Completed \
--project "TaskManager"
Generates: A runnable app — Model, Controller, HomeController, 5 CRUD views + Home pages, ApplicationDbContext, Program.cs, appsettings.json, Tailwind layout & build tooling
4. Generate DbContext
Option A: Auto-generate from Models folder
genmac csp.data.context.auto <ProjectName> [--models-path <path>] [--output <filename>]
Example:
# Scan Models folder and auto-generate DbContext
genmac csp.data.context.auto MyApp
# Custom Models path
genmac csp.data.context.auto MyApp --models-path src/Models --output MyDbContext.cs
Generates: Complete DbContext with all models and their relationships auto-detected
Option B: Generate for specific model
genmac csp.data.context <ProjectName> <ModelName> <attributes...>
Example:
genmac csp.data.context BlogApp Post \
string:title \
text:content \
references:user:userId:Author:guid \
hasmany:comment:Comments
Generates: DbContext with automatic relationship configuration
Data Types
| Type | Syntax | Example |
|---|---|---|
| String | string:name:req:Label:maxlen |
string:title:required:Title:100 |
| Integer | int:name:req:Label:default:min:max |
int:count:required:Count:0:1:100 |
| Decimal | decimal:name:req:Label:default:min:max |
decimal:price:required:Price:0.00:0:10000 |
| Bool | bool:name:req:Label:default |
bool:isActive:required:"Is Active":true |
| DateTime | datetime:name:req:Label |
datetime:createdAt:required:"Created At" |
| Long | long:name:req:Label:default:min:max |
long:fileSize:required:"File Size":0 |
| Double | double:name:req:Label:default:min:max |
double:rating:optional:Rating:0.0:0:5 |
| Guid | guid:name:req:Label |
guid:externalId:optional:"External ID" |
| Enum | enum:name:req:Label:values:default |
enum:status:required:Status:"New,Active":New |
| Text | text:name:req:Label:maxlen |
text:description:optional:Description:5000 |
email:name:req:Label |
email:contact:required:Email |
|
| Phone | phone:name:req:Label |
phone:mobile:optional:Mobile |
| URL | url:name:req:Label |
url:website:optional:Website |
| File | file:name:req:Label:storage |
file:avatar:optional:Avatar:s3 |
| JSON | json:name:req:Label |
json:metadata:optional:Metadata |
Security Types
| Type | Syntax | Use Case |
|---|---|---|
| Encrypted | encrypted:name:req:Label |
Credit cards, SSN, sensitive data |
| Password | password:name:req:Label:maxlen:minlen |
User passwords (auto-hashed) |
| Secret | secret:name:req:Label:type |
API keys, tokens, credentials |
Aliases: Use algorithm names directly: aes, bcrypt, argon2, chacha20
Relationships
| Type | Syntax | Description |
|---|---|---|
| BelongsTo | belongsto:Entity:fkName:Label:idType |
Many-to-one (foreign key) |
| References | references:Entity:fkName:Label:idType |
Same as belongsto (Rails-style) |
| HasMany | hasmany:Entity:Label |
One-to-many collection |
| HasOne | hasone:Entity:Label |
One-to-one relationship |
| HABTM | habtm:Entity:Label |
Many-to-many (join table) |
Example:
genmac csp.model Post \
string:title \
references:user:userId:Author:guid \
hasmany:comment:Comments \
habtm:tag:Tags
Common Workflows
REST API Application
# 1. Generate models
genmac csp.model Product id:long string:name decimal:price int:stock
genmac csp.model Category id:long string:name
# 2. Generate controllers
genmac asp.controller Product
genmac asp.controller Category
# 3. Generate DbContext automatically from all models
genmac csp.data.context.auto MyApp
# 4. Configure in Program.cs and run!
MVC Application
# Generate complete MVC app with one command
genmac asp.tailwind Product \
name:string:required:Name \
description:text:optional:Description \
price:decimal:required:Price \
stock:int:required:Stock \
isActive:bool:optional:"Is Active" \
--project "MyStore"
# Creates a runnable app: Model, Controllers, Views, DbContext,
# Program.cs, appsettings.json, Tailwind layout + build tooling.
# Then: ./setup-tailwind.sh && dotnet ef database update && dotnet run
E-Commerce Example
# Product with relationships
genmac asp.controller-with-attributes Product \
id:long \
string:name:required:Name:200 \
string:sku:required:SKU:50 \
decimal:price:required:Price:0.00:0:10000 \
int:stock:required:Stock:0 \
text:description:optional:Description \
belongsto:category:categoryId:Category:long \
hasmany:review:Reviews \
habtm:tag:Tags \
--route=products
Secure User System
genmac csp.model User id:guid \
string:username:required:Username:50 \
email:email:required:Email \
password:password:required:Password:100:8 \
phone:mobile:optional:Mobile \
bool:isVerified:required:"Is Verified":false \
encrypted:apiKey:optional:"API Key" \
hasone:profile:Profile
Next Steps
- Read the Detailed Guide - Learn all features and data types
- Check Examples - See real-world usage patterns
- Quick Reference - Keep as a syntax cheatsheet
Features
✅ Models - C# models with Data Annotations
✅ REST APIs - Full CRUD controllers with 30+ endpoints
✅ MVC Apps - Complete web apps with Tailwind CSS
✅ DbContext - Entity Framework with relationships
✅ Security - Built-in encryption and password hashing
✅ Validation - Automatic validation attributes
✅ Relationships - BelongsTo, HasMany, HasOne, HABTM
✅ Bulk Operations - Import/export, bulk create/update/delete
✅ Soft Delete - Mark as deleted without removing data
✅ Pagination - Built-in paging and sorting
✅ Search - Full-text search capabilities
Contributing
Issues and pull requests are welcome!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Optional: Set up 'gmc' short alias by running: curl -s https://raw.githubusercontent.com/razaibi/GenMac/main/install-alias.sh | bash