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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package EzDbSchema.Cli --version 9.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
- Analyze Database Schema
ezdb analyze --connection "Server=myserver;Database=mydb;User Id=sa;Password=****;TrustServerCertificate=True"
- Generate Code
ezdb generate --connection "..." --language csharp --output ./output
- 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
- 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
- Generate TypeScript Models with TypeORM
ezdb generate \
--connection "..." \
--language typescript \
--orm typeorm \
--output ./src/models
- Export Markdown Documentation
ezdb export \
--connection "..." \
--format markdown \
--output docs/schema.md \
--include-relationships \
--include-constraints
- 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 stringEZDB_OUTPUT_PATH
: Default output pathEZDB_TEMPLATE_PATH
: Default template pathEZDB_CONFIG_FILE
: Default config file path
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions 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.
Added comprehensive CLI tool for database schema analysis and code generation