Phase 5 transforms EntityClassGenerator from a single-page UI into a structured 5-step wizard for guided entity class generation from SQL Server databases.
MainWindow (Title bar + Frame)
└─ WizardView (Container)
├─ LeftPanel
│ └─ StepIndicator (Steps 1-5 with titles)
├─ Separator (Vertical divider)
├─ CenterPanel
│ └─ ContentControl (dynamic step content)
│ ├─ Step1ConnectionView
│ ├─ Step2TablesView
│ ├─ Step3NamingView
│ ├─ Step4OutputView
│ └─ Step5PreviewView
└─ BottomBar
├─ Cancel Button
├─ Progress Bar + Status
├─ Back Button
├─ Next Button (steps 1-4)
└─ Generate Button (step 5)
MainWindow
└─ DataContext: WizardViewModel
├─ Exposes: MainViewModel (for step views)
├─ Properties:
│ ├─ CurrentStep (1-5)
│ ├─ CanGoBack, CanGoNext, CanGenerate
│ ├─ IsBusy, StatusMessage
│ ├─ Step1Valid, Step2Valid, ... Step5Valid
│ └─ PreviewEntity, PreviewDbContext, PreviewFluentConfig
│
├─ Commands:
│ ├─ GoBackCommand
│ ├─ GoNextCommand (loads preview on step 5)
│ └─ GenerateCommand
│
└─ Listeners (auto-validation on MainViewModel changes):
├─ ServerName → validates Step1
├─ DatabaseName → validates Step1
├─ SelectedCount → validates Step2
├─ Namespace → validates Step3
├─ DbContextName → validates Step3
└─ OutputDirectory → validates Step4
Step Views (Each binds to MainViewModel)
├─ Step1ConnectionView
│ ├─ Inputs: ServerName, DatabaseName, UseWindowsAuth, Username, Password
│ ├─ Commands: TestConnectionCommand, LoadTablesCommand
│ └─ Validation: Non-empty server & database
│
├─ Step2TablesView
│ ├─ Inputs: SelectedSchema, TableFilter, DataGrid checkboxes
│ ├─ Commands: SelectAllVisibleCommand, DeselectAllCommand, InvertSelectionCommand
│ ├─ Display: SelectedCount (# of tables selected)
│ └─ Validation: At least 1 table selected
│
├─ Step3NamingView
│ ├─ Inputs: Namespace, DbContextName, ClassStyle, PropertyStyle,
│ │ PrefixToRemove, SuffixToRemove, ClassSuffix, SingularizeClassNames
│ └─ Validation: Non-empty Namespace & DbContextName
│
├─ Step4OutputView
│ ├─ Inputs: OutputDirectory, UseNullableReferenceTypes, UseDataAnnotations, UseFluentApi
│ ├─ Placeholder: Browse button (not wired in Phase 5)
│ └─ Validation: Valid directory path format
│
└─ Step5PreviewView
├─ Display: AvalonEdit tabs (Entity, DbContext, FluentConfig)
├─ DataContext: WizardViewModel (accesses preview properties)
└─ Always valid (preview always available)
| Step | Valid When | Invalid Message |
|---|---|---|
| 1 | Server ≠ "" AND Database ≠ "" | Missing server or database |
| 2 | SelectedCount > 0 | No tables selected |
| 3 | Namespace ≠ "" AND DbContextName ≠ "" | Missing namespace or DbContext name |
| 4 | OutputDirectory matches valid path pattern | Invalid directory path |
| 5 | Always (preview generated on step 5 entry) | N/A |
Step 1: Connection
↓ (Next enabled if Step1Valid)
Step 2: Tables
↓ (Next enabled if Step2Valid)
Step 3: Naming
↓ (Next enabled if Step3Valid)
Step 4: Output
↓ (Next enabled if Step4Valid, trigger preview load)
Step 5: Preview
↓ (Generate enabled if Step5Valid)
└─ Generate() → MainViewModel.GenerateAsync() → Output files
Back button at every step returns to previous step.
Cancel button exits wizard (placeholder for step check).
- Purpose: Orchestrate wizard navigation and validation
- Responsibilities:
- Track current step
- Validate each step's requirements
- Load preview on step 5
- Delegate generation to MainViewModel.GenerateAsync()
- Dependencies: MainViewModel (composition)
- Purpose: Host wizard UI and step switching
- Responsibilities:
- Render step indicator sidebar
- Switch step content dynamically
- Render navigation buttons
- Display progress bar and status
- Dependencies: WizardViewModel, Step1-5 Views
- Purpose: Individual step UI and input
- Responsibilities:
- Bind to MainViewModel properties
- Execute MainViewModel commands
- Display step-specific UI
- Dependencies: MainViewModel (for bindings)
- Purpose: XAML binding helpers
- Types:
StepIndicatorConverter: Step → Brush colorBoolToVisibilityConverter: bool → VisibilityShowNextButtonConverter: step == 5 → hide/show NextShowGenerateButtonConverter: step != 5 → hide/show GenerateNextButtonTextConverter: step → button textStepContentConverter: step → view contentInverseBoolConverter: (existing) bool → !bool
CurrentStep: 1-5 // Current wizard step
Step1Valid: bool // Connection valid
Step2Valid: bool // Tables selected
Step3Valid: bool // Naming configured
Step4Valid: bool // Output configured
Step5Valid: bool // Always true
CanGoBack: bool = CurrentStep > 1
CanGoNext: bool = CurrentStep < 5 && CurrentStepValid
CanGenerate: bool = CurrentStep == 5 && Step5Valid
IsBusy: bool // Generation in progress
StatusMessage: string // Current status
PreviewEntity: string // Entity code snippet
PreviewDbContext: string // DbContext code snippet
PreviewFluentConfig: string // Fluent config snippet
HasExistingFiles: bool // Placeholder for Phase 6ServerName, DatabaseName, UseWindowsAuth, Username, Password
TableFilter, SelectedSchema
Namespace, DbContextName, OutputDirectory
ClassStyle, PropertyStyle, NamespaceStyle, FileStyle
ClassSuffix, PrefixToRemove, SuffixToRemove, SingularizeClassNames
UseNullableReferenceTypes, UseDataAnnotations, UseFluentApi
AllTables, TablesView, Schemas
StatusMessage, IsBusy, ProgressValue- Read: All properties for binding
- Write: Checkbox selection (IsSelected), text inputs
- Call: GenerateAsync() on step 5 completion
- Listen: Property changes for validation
- DI: WizardViewModel registered as singleton
- Start: Main window DataContext set to WizardViewModel
- Theme: MainViewModel.AppThemeChanged still fires for app theming
- Generation: Delegates to EntityGenerator, DbContextGenerator, FluentConfigurationGenerator (unchanged)
- File I/O: Delegates to CreateOnlyFileWriter (unchanged)
- Database: Delegates to SqlServerMetadataReader (unchanged)
- Diff View: Show existing vs generated code side-by-side
- File Browser: Browse button for output directory
- Keyboard Navigation: Enter = Next, Escape = Cancel
- Error Messages: Display validation errors per step
- Progress Resumption: Save/load wizard state
- Preview Comparison: Show existing file contents in preview
- Themes in Wizard: Allow theme switching mid-wizard
- Batch Generation: Generate multiple namespaces
- History: Recent connections/settings
- Undo/Redo: Within wizard navigation
- Connection validation logic
- Table selection state
- Naming configuration
- Output path validation
- Step validation transitions
- Preview generation
- Wizard navigation flow (1→5 and back)
- Button enable/disable state
- DataGrid selection sync
- Preview code generation
- Click through all 5 steps
- Verify navigation buttons enable/disable
- Verify validation blocks Next button
- Generate entities end-to-end
- Test Cancel at each step
- Test Back navigation
- Preview Loading: Async on step 5 entry (LoadPreviewAsync)
- Code Generation: Uses existing EntityGenerator (optimized)
- AvalonEdit: Read-only, no syntax highlighting (lighter weight)
- Binding: MVVM Community Toolkit (compiled bindings in release)
- All interactive controls have
AutomationProperties.AutomationId - Button labels clearly indicate action
- Step indicator numbered and titled
- Status messages announced via TextBlock
- Tab order follows visual flow
- Color contrast meets AA standard (WPF-UI theme)
- Keyboard navigation supported (Tab, Enter, Escape)
- Password field uses PasswordBox (not bound to ViewModel)
- Connection string built via
SqlServerConnectionStringBuilder - No credentials logged
- Output files checked for overwrite protection
- Database metadata read-only operation