EzDbSchema.Cli 9.0.2

dotnet tool install --global EzDbSchema.Cli --version 9.0.2                
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 EzDbSchema.Cli --version 9.0.2                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=EzDbSchema.Cli&version=9.0.2                
nuke :add-package EzDbSchema.Cli --version 9.0.2                

EzDbSchema CLI Tool

A command-line interface for EzDbSchema that allows you to analyze database schemas, generate code, and export schema documentation.

Installation

Using .NET Tool

dotnet tool install --global EzDbSchema.Cli

Building from Source

git clone https://github.com/rvegajr/ez-db-schema-core.git
cd ez-db-schema-core/Src/EzDbSchema.Cli
dotnet build
dotnet pack

Usage

Basic Commands

  1. Analyze Database Schema
ezdb analyze --connection "Server=myserver;Database=mydb;User Id=sa;Password=****;TrustServerCertificate=True"
  1. Generate Code
ezdb generate --connection "..." --language csharp --output ./output
  1. Export Schema Documentation
ezdb export --connection "..." --format markdown --output schema.md

Command Options

Analyze Command
ezdb analyze [options]

Options:

  • --connection, -c: Connection string (required)
  • --output, -o: Output file path for schema JSON
  • --schema, -s: Database schema name (default: dbo)
  • --verbose, -v: Enable verbose output
Generate Command
ezdb generate [options]

Options:

  • --connection, -c: Connection string (required)
  • --language, -l: Target language (csharp, typescript, python, go, java)
  • --output, -o: Output directory (required)
  • --template, -t: Template directory
  • --namespace, -n: Root namespace
  • --orm: ORM framework (ef, typeorm, sqlalchemy)
  • --include-views: Include database views
  • --generate-tests: Generate unit tests
Export Command
ezdb export [options]

Options:

  • --connection, -c: Connection string (required)
  • --format, -f: Output format (json, markdown, html)
  • --output, -o: Output file path
  • --include-relationships: Include relationship diagrams
  • --include-constraints: Include constraint details

Examples

  1. Generate C# Entity Framework Models
ezdb generate \
  --connection "Server=localhost;Database=northwind;Trusted_Connection=True;" \
  --language csharp \
  --orm ef \
  --output ./Models \
  --namespace MyApp.Domain \
  --include-views
  1. Generate TypeScript Models with TypeORM
ezdb generate \
  --connection "..." \
  --language typescript \
  --orm typeorm \
  --output ./src/models
  1. Export Markdown Documentation
ezdb export \
  --connection "..." \
  --format markdown \
  --output docs/schema.md \
  --include-relationships \
  --include-constraints
  1. Analyze and Save Schema
ezdb analyze \
  --connection "..." \
  --output schema.json \
  --schema dbo \
  --verbose

Configuration File

You can create an ezdb.json configuration file to store common settings:

{
  "connectionStrings": {
    "dev": "Server=dev-db;Database=myapp;...",
    "prod": "Server=prod-db;Database=myapp;..."
  },
  "defaultLanguage": "csharp",
  "defaultOrm": "ef",
  "templates": {
    "path": "./templates",
    "customMappings": {
      "datetime": "DateTimeOffset",
      "varchar": "string"
    }
  },
  "output": {
    "path": "./generated",
    "cleanDirectory": true
  }
}

Then use it with:

ezdb generate --config ezdb.json --connection-name dev

Templates

EzDbSchema CLI supports custom templates using Handlebars syntax. Create a template directory with:

templates/
  ├── entity/
  │   ├── class.hbs
  │   ├── interface.hbs
  │   └── dto.hbs
  ├── dbcontext/
  │   └── context.hbs
  └── helpers/
      └── types.hbs

Use custom templates with:

ezdb generate --template ./templates

Environment Variables

  • EZDB_CONNECTION_STRING: Default connection string
  • EZDB_OUTPUT_PATH: Default output path
  • EZDB_TEMPLATE_PATH: Default template path
  • EZDB_CONFIG_FILE: Default config file path

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

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

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.  net9.0 was computed.  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. 
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
9.0.2 34 2/19/2025
9.0.1 31 2/19/2025

Added comprehensive CLI tool for database schema analysis and code generation