Open Closed

abp suite generate - how to use ? #10235


User avatar
0
abmag created

Give detailed help and examples on how to use 'abp suite generate'


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    1. Solution Below is a concise, practical guide to the abp suite generate CLI command that lets you run ABP Suite’s CRUD code generation from the command line using a JSON entity definition file.

    Prerequisites

    • ABP Suite installed (with a valid license for ABP Commercial).
    • ABP CLI installed: dotnet tool install -g Volo.Abp.Cli
    • An ABP solution (the .sln path you’ll pass with -s).
    • A Suite entity JSON file (the model describing your entity, properties, UI preferences, etc.).

    Command abp suite generate -e <entity-json-path> -s <solution-sln-path> [options]

    Required parameters

    • -e, --entity: Path to the Suite entity definition JSON file.
    • -s, --solution: Path to your solution (.sln) file that will be modified (server and UI code generated/inserted).

    Common options

    • --ui angular|mvc|blazor: Forces a specific UI target if your solution contains multiple UIs or if you want to generate for one UI only.
    • --overwrite true|false: Overwrite existing generated files (default is safer behavior; set true to refresh generated code).
    • --dry-run true|false: Shows what would be generated without writing files (useful to review).
    • --module <ModuleName>: Generate into a specific module of a modular solution.
    • --include-tests true|false: Generate corresponding test projects and tests where supported.

    Typical usage examples

    1. Basic generation (single module, single UI) abp suite generate -e C:\Users&lt;you>.suite\entities\Country.json -s C:\dev\MyApp\MyApp.sln

    2. Generate only for Angular UI abp suite generate -e ..suite\entities\Product.json -s .\MyApp.sln --ui angular

    3. Overwrite previously generated files (refresh after entity changes) abp suite generate -e ..suite\entities\Order.json -s .\MyApp.sln --overwrite true

    4. Dry run to preview changes abp suite generate -e ..suite\entities\Customer.json -s .\MyApp.sln --dry-run true

    5. Generate into a specific module in a modular solution abp suite generate -e ..suite\entities\Invoice.json -s .\MyMicroserviceApp.sln --module AccountingService

    What the command does

    • Reads your entity JSON and generates end-to-end code:
      • Domain, EF Core mapping, repository, application contracts, application service, HTTP API.
      • UI pages/components (Angular/MVC/Blazor) for CRUD, navigation entries, menus, localization entries, permissions.
      • Optionally test scaffolding.
    • Integrates with existing solution structure created by ABP templates.
    • Respects ABP best practices (DTOs, permissions, validation, application services, layered architecture).

    Authoring the entity JSON A minimal example to get started (Country.json): { "name": "Country", "namespace": "MyCompany.MyApp", "tableName": "AppCountries", "primaryKey": "Guid", "aggregateRoot": true, "audited": true, "fields": [ { "name": "Name", "type": "string", "maxLength": 128, "required": true }, { "name": "Code", "type": "string", "maxLength": 8, "required": true, "unique": true } ], "ui": { "create": { "visible": true }, "edit": { "visible": true }, "delete": { "visible": true }, "list": { "columns": [ { "name": "Name", "width": 200 }, { "name": "Code", "width": 120 } ] } }, "permissions": { "groupName": "Country", "default": "MyApp.Countries", "create": "MyApp.Countries.Create", "update": "MyApp.Countries.Update", "delete": "MyApp.Countries.Delete" } }

    Recommended workflow

    • Create/update your entity JSON definition (use ABP Suite UI once to export JSON, or author by hand following your established patterns).
    • Keep entity JSON files under a .suite/entities folder in your repo to version-control them.
    • Run abp suite generate whenever your entity model changes.
    • Use --dry-run first to verify, then run with --overwrite true if you are refreshing generated files.
    • After generation, run database migrations if entity/schema changes were included:
      • Add migration: dotnet ef migrations add "Added_Country" -p <Your.DbMigrationsProject> -s <Your.HttpApi.Host>
      • Update database: dotnet ef database update -p <Your.DbMigrationsProject> -s <Your.HttpApi.Host>
    • Build and run your app; verify the new menu and CRUD pages.

    Troubleshooting tips

    • The solution path (-s) must point to an existing .sln from an ABP-based solution; ensure the UI project exists if you target a specific UI.
    • If you have customizations on generated files, they may be overwritten when using --overwrite true; consider partial classes/partials/partial methods, or keep custom code out of generated regions/files.
    • Ensure your ABP Suite version matches your solution’s ABP version range to avoid template incompatibilities.
    • Run from a developer command prompt with write permissions to your repo.
    1. Sources
    • ABP 5.3 release notes (introducing abp suite generate capability via CLI):
      • https://abp.io/community/articles/5jw3pda1

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can check details here: https://abp.io/docs/latest/suite

    Thanks.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 17, 2025, 07:08
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.