ABP Framework — Development Flow
Adding a new entity end-to-end in the ABP v10.x layered template.
Trigger
"ABP add new entity/feature", "end-to-end CRUD", "development flow", "how do I start".
Flow
- Domain/Entities —
Book : AggregateRoot<Guid>(private setter, constructor invariant,Check.NotNullOrWhiteSpace). - Domain.Shared —
BookConsts, enum. - Domain (opt.) — custom
IBookRepository : IRepository<Book,Guid>only if a custom query is needed. - EntityFrameworkCore —
DbSet<Book>+OnModelCreating:
```csharp
builder.Entity<Book>(b => { b.ToTable(Prefix+"Books"); b.ConfigureByConvention(); b.Property(x=>x.Name).IsRequired().HasMaxLength(128); });
```
- Migration:
```bash
cd src/MyProject.EntityFrameworkCore
dotnet ef migrations add Added_Book
dotnet run --project ../MyProject.DbMigrator # apply + seed
```
- Application.Contracts —
BookDto : EntityDto<Guid>,CreateBookDto([Required]/[Range]),IBookAppService : IApplicationService. - Mapping — Mapperly
[Mapper] partial class BookMapper : MapperBase<Book, BookDto>. - Application —
BookAppService : ApplicationService, IBookAppService;[Authorize(...)],GuidGenerator.Create(),ObjectMapper.Map<>(). - Localization —
*.Domain.Shared/Localization/*/en.json. - Permission —
MyProjectPermissions.Books.Create(Application.Contracts). - Test —
*ApplicationTestBase,GetRequiredService<IBookAppService>().
Commands
dotnet build
dotnet ef migrations add Name # in the EntityFrameworkCore project
dotnet run --project ../MyProject.DbMigrator
abp generate-proxy -t ng
Checklist
Entity → Shared → (repo) → EF config + ConfigureByConvention → migration/DbMigrator → DTO+interface → Mapperly → service+authorize → localization → permission → test.
Related
- DDD · EF Core · Object Mapping · Authorization · Testing · Dependency Rules
- ABP Docs: https://abp.io/docs/latest/tutorials