Skip to main content
Any Framework

Command-line interface for EzDbSchema - Analyze database schemas, generate code, and export documentation

Published
Feb 19, 2025
1y ago
Total Downloads
793
793

Install

dotnet add package EzDbSchema.Cli --version 9.0.2

No framework information available.

README

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.

Changes from Previous Version

No structural changes between v9.0.1 and v9.0.2.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.