Tool for generating dotnet code
Project description
Dotnet generate
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:
- Fork/Clone this project.
- Navigate to project dir.
- Edit the code.
- Install the CLI tool.
pip3 install --editable .
- Check that tool is installed
dotnet-generate --help
- If everything works, make new pull request?
Built with
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dotnet-generate-0.5.0.tar.gz
.
File metadata
- Download URL: dotnet-generate-0.5.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 794d955a8ee9da85d232ff42512de22d952583e7c0101f5e92481e9778f10c25 |
|
MD5 | f676125557a889e5cf4a59f970f0d3b8 |
|
BLAKE2b-256 | 3a2b25f4d589e98299f4ced38903732daca6ea0ae43724a7627abbae625adfda |
File details
Details for the file dotnet_generate-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: dotnet_generate-0.5.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ea8581f998cd37acdd891a01f523167c9391ed16366670144d49dbdf21c9f26 |
|
MD5 | 6efe6dffd34f6c049ce5f5a4ad9289f0 |
|
BLAKE2b-256 | fea0885ef5d3b43360d50c1045e7ba8808fb6c29ed2498257a4e00aeb4cdabbb |