Feature Commands
Add framework features and modules to your PearDrop application.
peardrop feature auth
Inject authentication into a minimal PearDrop template.
peardrop feature auth
What It Does:
- Adds PearDrop.Authentication NuGet package to server project
- Updates Program.cs with authentication registration
- Adds login/registration UI (if not present)
- Configures connection string for auth database
- Creates initial migration for auth schema
Added configuration:
// Program.cs
builder.Services.AddPearDropAuthentication(builder.Configuration);
// appsettings.json
{
"ConnectionStrings": {
"PearDrop-Auth": "Server=localhost,1440;Database=MyApp;..."
}
}
When to Use
- Starting with minimal template - Add auth to
peardrop initprojects - Custom auth requirements - Modify auth after injection
After Injection
- Review auth configuration - Check appsettings.json for connection strings
- Run migrations -
peardrop migrateto create auth tables - Configure auth providers - Use
peardrop authcommands to add Entra ID - Customize UI - Modify login/registration pages
peardrop feature multitenancy
Inject multi-tenancy support into your application.
# Host-based tenant resolution
peardrop feature multitenancy --strategy host
# URL-based tenant resolution
peardrop feature multitenancy --strategy url
What It Does:
- Adds PearDrop.Multitenancy NuGet package
- Configures tenant resolution strategy (host, URL, claim)
- Updates DbContext with tenant filtering
- Adds tenant management UI
- Creates multitenancy migrations
Added configuration:
// Program.cs
builder.Services.AddPearDropMultitenancy(builder.Configuration);
// appsettings.json
{
"PearDrop": {
"Multitenancy": {
"Strategy": "host",
"DefaultTenantId": "00000000-0000-0000-0000-000000000001"
}
},
"ConnectionStrings": {
"PearDrop-Multitenancy": "Server=localhost,1440;Database=MyApp;..."
}
}
Tenant Resolution Strategies
| Strategy | Description | Example |
|---|---|---|
host | Subdomain-based | tenant1.myapp.com, tenant2.myapp.com |
url | URL path segment | myapp.com/tenant1, myapp.com/tenant2 |
claim | JWT claim | User token contains tenant_id claim |
When to Use
- SaaS applications - Each customer gets isolated data
- White-label products - Branded per tenant
- Enterprise deployments - Department/division isolation
After Injection
- Run migrations -
peardrop migratefor tenant tables - Configure tenant resolution - Update appsettings.json strategy
- Implement tenant creation - Add tenant onboarding workflow
- Test tenant isolation - Verify data separation
peardrop add module
Add a PearDrop framework module to your application.
# Add files module
peardrop add module files
# Add messaging module
peardrop add module messaging
Available Modules:
| Module | Purpose | What It Provides |
|---|---|---|
files | File management | Upload, download, versioning, sharing |
messaging | In-app messaging | User-to-user messages, notifications |
For Each Module, It:
- Adds NuGet package -
PearDrop.{Module} - Registers services - Calls
AddPearDrop{Module}()in Program.cs - Configures connection strings - Module-specific database connection
- Adds API endpoints - Framework module controllers
- Creates migrations - Module schema setup
- Updates manifest - Adds module to
usedModulesinpeardrop.json
Example: Files Module
// Added to Program.cs
builder.Services.AddPearDropFiles(builder.Configuration);
// Added to appsettings.json
{
"ConnectionStrings": {
"PearDrop-Files": "Server=localhost,1440;Database=MyApp;..."
},
"PearDrop": {
"Files": {
"StorageProvider": "AzureBlob",
"MaxFileSize": 104857600
}
}
}
When to Use
- Rapid prototyping - Need file uploads without custom implementation
- Standard features - Messaging/files are commodity features
- Framework consistency - Follow PearDrop patterns
When NOT to Use
- Custom requirements - Need domain-specific file handling
- High customization - Module doesn't fit your workflow
- Learning DDD - Better to build custom for understanding
After Adding Module
- Run migrations -
peardrop migratefor module tables - Configure module - Update appsettings.json with module settings
- Add UI references - Import module components in Blazor pages
- Test module endpoints - Verify APIs work with your auth
peardrop feature radzen
Add Radzen component library with helper integrations to your Blazor WASM client.
peardrop feature radzen
What It Does:
- Adds Radzen.Blazor NuGet package to client project
- Registers Radzen services -
AddRadzenComponents()in Program.cs - Adds Radzen theme to App.razor - Material design by default
- Injects Radzen.Blazor.min.js via runtime script loading (avoids Parcel bundler conflicts)
- Sets up PearDrop.Helpers.Radzen.Client for integrated UI helpers
- Configures _Imports.razor with
@using Radzendirective
Added configuration:
// Program.cs
using Radzen;
builder.Services.AddRadzenComponents();
// _Imports.razor
@using Radzen
// App.razor
<RadzenTheme Theme="material" />
<RadzenComponents />
// Assets/index.pug (runtime injection)
script.
const radzenScript = document.createElement('script');
radzenScript.src = '/_content/Radzen.Blazor/Radzen.Blazor.min.js';
document.body.appendChild(radzenScript);
When to Use
- Building rich UIs - Radzen provides 70+ pre-built components
- Rapid prototyping - No CSS framework needed
- PearDrop consistency - Integrated with email/SMS helpers for styled forms
- Material design fans - Modern, professional look out-of-the-box
After Injection
- Restore packages -
dotnet restoreto pull Radzen and helper libraries - Use in components - Import Radzen components:
<RadzenButton Text="Click Me" /> - Customize theme - Modify Material theme or use Fluent variant
- Build client -
npm install && npm run buildin client directory
PearDrop.Helpers.Radzen.Client (Side Dialog Layouts)
The Radzen feature also enables PearDrop.Helpers.Radzen.Client, which includes reusable side-dialog layouts:
PearDropSideDialogLayout- For non-form dialogs (confirmations, review panels)PearDropFormSideDialogLayout- For form dialogs withEditForm+FluentValidation
Required imports:
@using PearDrop.Helpers.Radzen.Client.SlideOut
@using Microsoft.AspNetCore.Components.Forms
@using Blazored.FluentValidation
Example: Non-form side dialog
<PearDropSideDialogLayout
Icon="folder_open"
Title="Move Items"
Description="Choose a destination folder for selected files."
PrimaryButtonText="Move"
SecondaryButtonText="Cancel"
IsPrimaryButtonBusy="@isSaving"
OnPrimaryClick="OnMoveAsync"
OnSecondaryClick="OnCancelAsync">
<Content>
<RadzenTree Data="@folders" />
</Content>
</PearDropSideDialogLayout>
Example: Form side dialog
<PearDropFormSideDialogLayout
Icon="edit"
Title="Rename Item"
Description="Provide a new name."
EditContext="@editContext"
PrimaryButtonText="Save"
SecondaryButtonText="Cancel"
IsPrimaryButtonBusy="@isSaving"
OnValidSubmit="OnSaveAsync"
OnSecondaryClick="OnCancelAsync">
<Content>
<FluentValidationValidator />
<RadzenTextBox @bind-Value="@model.Name" Name="Name" />
</Content>
</PearDropFormSideDialogLayout>
When to use these helpers:
- Consistent side-panel UX across modules
- Shared button layout, loading state, and dialog framing
- Form workflows needing
EditContext+ validation
peardrop add email-helper
Add PearDrop.Helpers email service with SMTP configuration.
peardrop add email-helper
What It Does:
- Adds PearDrop.Helpers NuGet package
- Registers email service -
IEmailServicefor DI - Adds SMTP configuration to appsettings.json
- Provides templating support - Razor email templates
Added configuration:
// Program.cs
builder.Services.AddPearDropEmailHelper(builder.Configuration);
// appsettings.json
{
"PearDrop": {
"Email": {
"SmtpHost": "smtp.gmail.com",
"SmtpPort": 587,
"UseSsl": true,
"FromAddress": "noreply@myapp.com",
"FromName": "MyApp"
}
}
}
Usage in code:
public class SendWelcomeEmailCommandHandler : ICommandHandler<...>
{
private readonly IEmailService emailService;
public async Task<CommandResult> Handle(...)
{
await emailService.SendAsync(new EmailMessage
{
To = user.Email,
Subject = "Welcome to MyApp",
Body = await RenderTemplateAsync("welcome", user),
IsHtml = true
});
}
}
When to Use
- Transactional emails - Welcome, password reset, notifications
- Consistent styling - Centralized email templates
- SMTP flexibility - Easy provider switching
After Adding
- Configure SMTP credentials - Update appsettings.json or use secrets
- Create email templates - Add Razor templates in
EmailTemplates/ - Test email sending - Send test email to verify SMTP config
- Add to CI/CD secrets - Store SMTP password securely
Feature Combinations
Common feature combinations for different application types:
Simple Internal Tool
peardrop init MyApp
peardrop feature auth
peardrop feature radzen
# Done - single tenant with auth and Radzen UI
Modern SaaS Application
peardrop init MyApp
peardrop feature auth
peardrop feature multitenancy --strategy host
peardrop feature radzen
peardrop add email-helper
# Multi-tenant SaaS with Radzen UI and email notifications
Enterprise Application
peardrop init MyApp
peardrop feature auth
peardrop feature multitenancy --strategy claim
peardrop feature radzen
peardrop add module files
peardrop add module messaging
peardrop add email-helper
# Full-featured enterprise app with professional UI
Rich Admin Dashboard
peardrop init MyApp
peardrop feature auth
peardrop feature radzen
peardrop add module files
peardrop add email-helper
peardrop add sms-helper
# Admin dashboard with file management and notifications
Troubleshooting
Feature Already Exists
Problem: Feature injection fails with "feature already configured"
Solution:
- Check Program.cs for existing
AddPearDrop{Feature}()calls - Review appsettings.json for feature configuration
- Feature may have been added during
peardrop initwith non-minimal template
Module Conflicts
Problem: Module registration throws DI errors
Solution:
- Ensure module package version matches framework version
- Run
peardrop updateto align package versions - Check for duplicate service registrations in Program.cs
Migration Failures After Feature Injection
Problem: peardrop migrate fails after adding feature
Solution:
# Clean and rebuild
dotnet clean
dotnet build
# Try migration again
peardrop migrate
# If still fails, manually add migration
dotnet ef migrations add AddAuthenticationModule --context AuthDbContext
Next Steps
- Auth Commands - Configure authentication providers
- Domain Commands - Build your domain model
- Utility Commands - Migrations and updates