Skip to main content

Dotnet generate

PyPI

Script generator for dotnet core 2.x

Tool for making it easier to generate MVC and API controllers in Asp.NET Core applications. Helps also with managing DB migrations and updates.

Installation

I have tested it with Python 3.6 only

Install it via pip/pip3 pip install dotnet-generate.

Examples

Examples executed in dotnet core 2.1 solution folder, with the following structure

├── DAL
│   └── AppDbContext.cs
├── Domain
│   ├── BaseEntity.cs
│   ├── Contact.cs
│   ├── ContactType.cs
│   ├── Domain.csproj
│   ├── Identity
│   │   ├── AppRole.cs
│   │   └── AppUser.cs
│   └── Person.cs
└── WebApp
    ├── Startup.cs
    ├── Program.cs
    ...

Migrations

To make new migrations run:

dotnet-generate migrate MigrationName

Migrate command has some additional options:

  • -u, -update for updating DB to latest migration.
  • -m, --mvc for creating MVC controllers.
  • -a, --api for creating API controllers.
  • -t, --try this option runs the tool without actually executing any commands, instead it will print those commands to console.

You can also combine these flags, for example you can generate shell script with all the commands as follows:

dotnet-generate migrate MigrationName -umat > script.sh

Which will produce the following script.sh

dotnet ef migrations add MigrationName --project DAL --startup-project WebApp
dotnet ef database update --project DAL --startup-project WebApp
cd WebApp/
dotnet aspnet-codegenerator controller -name PersonsController -actions -m Person -dc AppDbContext -outDir Controllers --useDefaultLayout --useAsyncActions --referenceScriptLibraries -f
dotnet aspnet-codegenerator controller -name ContactsController -actions -m Contact -dc AppDbContext -outDir Controllers --useDefaultLayout --useAsyncActions --referenceScriptLibraries -f
dotnet aspnet-codegenerator controller -name ContactTypesController -actions -m ContactType -dc AppDbContext -outDir Controllers --useDefaultLayout --useAsyncActions --referenceScriptLibraries -f
cd ../
cd WebApp/
dotnet aspnet-codegenerator controller -name PersonsController -actions -m Person -dc AppDbContext -outDir Api/Controllers -api --useAsyncActions -f
dotnet aspnet-codegenerator controller -name ContactsController -actions -m Contact -dc AppDbContext -outDir Api/Controllers -api --useAsyncActions -f
dotnet aspnet-codegenerator controller -name ContactTypesController -actions -m ContactType -dc AppDbContext -outDir Api/Controllers -api --useAsyncActions -f
cd ../

Db updating

For updating db run

dotnet-generate update

MVC controllers.

For generating MVC controllers run

dotnet-generate mvc

API controllers.

For generating API controllers run

dotnet-generate api

Installation for local build

If you want to make this tool better, then you can make local releases like this:

  1. Fork/Clone this project.
  2. Navigate to project dir.
  3. Edit the code.
  4. Install the CLI tool. pip3 install --editable .
  5. Check that tool is installed dotnet-generate --help
  6. If everything works, make new pull request?

Built with

Metadata

Release files for dotnet-generate 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dotnet-generate 0.5.0
File Size Uploaded Provenance Actions
dotnet-generate-0.5.0.tar.gz 3.5 kB Without provenance Details for dotnet-generate-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dotnet-generate 0.5.0
File Interpreter ABI Platform Actions
dotnet_generate-0.5.0-py3-none-any.whl Python 3 none any Details for dotnet_generate-0.5.0-py3-none-any.whl

Total release size: 8.2 kB

Release files / dotnet-generate-0.5.0.tar.gz

Download URL dotnet-generate-0.5.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
794d955a8ee9da85d232ff42512de22d952583e7c0101f5e92481e9778f10c25
BLAKE2b-256 checksum
How to use checksums
3a2b25f4d589e98299f4ced38903732daca6ea0ae43724a7627abbae625adfda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / dotnet_generate-0.5.0-py3-none-any.whl

Download URL dotnet_generate-0.5.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ea8581f998cd37acdd891a01f523167c9391ed16366670144d49dbdf21c9f26
BLAKE2b-256 checksum
How to use checksums
fea0885ef5d3b43360d50c1045e7ba8808fb6c29ed2498257a4e00aeb4cdabbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for dotnet-generate 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page