|
| 1 | +# ContosoUniversity Migration — Run 10 Report |
| 2 | + |
| 3 | +## Executive Summary |
| 4 | + |
| 5 | +**Run 10 revealed significant script gaps** when migrating ContosoUniversity — a Web Forms app with different patterns than WingtipToys. The migration scripts work well for WingtipToys-style apps but need enhancements for ContosoUniversity's inline styles and EF6 patterns. |
| 6 | + |
| 7 | +| Metric | Value | |
| 8 | +|--------|-------| |
| 9 | +| **Build Status** | ❌ FAILED (68 errors) | |
| 10 | +| **Layer 1 Time** | 1.17 seconds | |
| 11 | +| **Layer 2 Time** | 0.68 seconds | |
| 12 | +| **Date** | 2026-03-09 | |
| 13 | +| **Branch** | `squad/audit-docs-perf` | |
| 14 | + |
| 15 | +## Timing Details |
| 16 | + |
| 17 | +| Phase | Duration | |
| 18 | +|-------|----------| |
| 19 | +| Layer 1 (bwfc-migrate.ps1) | 1.17s | |
| 20 | +| Layer 2 (bwfc-migrate-layer2.ps1) | 0.68s | |
| 21 | +| **Total Script Time** | **1.85s** | |
| 22 | +| Build (failed) | 8.0s | |
| 23 | + |
| 24 | +## Script Bug Fixed During Run |
| 25 | + |
| 26 | +**Layer 2 line 1323:** `Get-ChildItem` returned a single object instead of array, causing `.Count` property error. Fixed by wrapping with `@()`: |
| 27 | +```powershell |
| 28 | +# Before (bug) |
| 29 | +$edmxFiles = Get-ChildItem -Path $SourcePath -Filter '*.edmx' ... |
| 30 | +# After (fix) |
| 31 | +$edmxFiles = @(Get-ChildItem -Path $SourcePath -Filter '*.edmx' ...) |
| 32 | +``` |
| 33 | + |
| 34 | +## Build Errors Discovered |
| 35 | + |
| 36 | +### Category 1: Style Attribute Quoting (42 errors) |
| 37 | +The source app uses inline BWFC style attributes like: |
| 38 | +```xml |
| 39 | +BackColor="White" ForeColor="#333333" BorderStyle="Solid" |
| 40 | +``` |
| 41 | + |
| 42 | +In Razor, these parse as C# identifiers (`White`, `Solid`, `Center`) instead of string literals. The script needs to quote these properly: |
| 43 | +```razor |
| 44 | +BackColor="White" ❌ Parses White as C# variable |
| 45 | +BackColor=@("White") ✅ Explicit string |
| 46 | +``` |
| 47 | + |
| 48 | +**Affected attributes:** BackColor, ForeColor, BorderColor, BorderStyle, HorizontalAlign, Font-Bold, etc. |
| 49 | + |
| 50 | +### Category 2: Hex Color Values (15 errors) |
| 51 | +Hex colors like `ForeColor="#333333"` cause preprocessor directive errors because `#` starts a C# preprocessor directive in certain contexts. |
| 52 | + |
| 53 | +### Category 3: Code-Behind Entity References (9 errors) |
| 54 | +Layer 2's Pattern A generated incorrect entity references: |
| 55 | +- `db.Items` — DbContext doesn't have an `Items` property |
| 56 | +- `db.Enrollmet_Logics` — Non-existent DbSet name |
| 57 | +- `db.strings` — Incorrectly detected entity type |
| 58 | + |
| 59 | +### Category 4: Event Handler Binding (2 errors) |
| 60 | +Methods referenced in `OnClick` attributes don't exist in the generated code-behind: |
| 61 | +- `btnSearchCourse_Click` |
| 62 | +- `search_Click` |
| 63 | + |
| 64 | +### Category 5: DbContext Constructor (1 error) |
| 65 | +The `Enrollmet_Logic.cs` model tries to instantiate `ContosoUniversityEntities()` without the required `DbContextOptions` parameter (EF Core requires DI). |
| 66 | + |
| 67 | +## Root Cause Analysis |
| 68 | + |
| 69 | +### ContosoUniversity vs WingtipToys |
| 70 | + |
| 71 | +| Aspect | WingtipToys | ContosoUniversity | |
| 72 | +|--------|-------------|-------------------| |
| 73 | +| **Inline Styles** | None (CSS classes) | Heavy use (40+ attributes) | |
| 74 | +| **Color Values** | None | Hex colors everywhere | |
| 75 | +| **EF Pattern** | Code-First | DB-First (.edmx) | |
| 76 | +| **GridView Usage** | Simple | Complex with nested styles | |
| 77 | +| **Table Controls** | Minimal | Heavy use of `<Table>` | |
| 78 | +| **SelectMethod** | Standard pattern | Non-standard patterns | |
| 79 | + |
| 80 | +The migration scripts were optimized for WingtipToys' patterns. ContosoUniversity uses significantly different patterns that require script enhancements. |
| 81 | + |
| 82 | +## Required Script Enhancements |
| 83 | + |
| 84 | +### Layer 1 Fixes Needed |
| 85 | + |
| 86 | +1. **Quote all BWFC style attribute values** |
| 87 | + - Detect known style attribute names (BackColor, ForeColor, etc.) |
| 88 | + - Ensure values are quoted as strings: `BackColor="White"` → `BackColor=@("White")` |
| 89 | + |
| 90 | +2. **Handle hex color values** |
| 91 | + - Convert `ForeColor="#333333"` to `ForeColor=@("#333333")` |
| 92 | + - Or: Remove inline colors, add TODO to move to CSS |
| 93 | + |
| 94 | +3. **Validate SelectMethod references** |
| 95 | + - Ensure methods exist in code-behind |
| 96 | + - Generate stubs if missing |
| 97 | + |
| 98 | +### Layer 2 Fixes Needed |
| 99 | + |
| 100 | +1. **Improve entity type detection** |
| 101 | + - Don't generate `db.Items` as a fallback |
| 102 | + - Parse actual DbSet properties from DbContext |
| 103 | + |
| 104 | +2. **Handle EF6 → EF Core DbContext properly** |
| 105 | + - Remove `DbModelBuilder` references |
| 106 | + - Add parameterless constructor option for legacy patterns |
| 107 | + - Or: Generate proper DI-based instantiation |
| 108 | + |
| 109 | +## Recommendations |
| 110 | + |
| 111 | +1. **ContosoUniversity is not a good BWFC migration candidate** — it uses patterns that don't map cleanly to BWFC (heavy inline styles, DB-first EF, non-standard code-behind). |
| 112 | + |
| 113 | +2. **Enhance scripts for broader compatibility** — but prioritize WingtipToys-style apps since those are the common migration path. |
| 114 | + |
| 115 | +3. **Add script validation** — detect problematic patterns early and warn users before migration starts. |
| 116 | + |
| 117 | +## Files Produced |
| 118 | + |
| 119 | +``` |
| 120 | +samples/AfterContosoUniversity/ |
| 121 | +├── About.razor # 68 build errors |
| 122 | +├── About.razor.cs |
| 123 | +├── Courses.razor |
| 124 | +├── Courses.razor.cs |
| 125 | +├── Home.razor |
| 126 | +├── Home.razor.cs |
| 127 | +├── Instructors.razor |
| 128 | +├── Instructors.razor.cs |
| 129 | +├── Students.razor |
| 130 | +├── Students.razor.cs |
| 131 | +├── Components/ |
| 132 | +│ ├── Layout/ |
| 133 | +│ │ ├── MainLayout.razor |
| 134 | +│ │ └── MainLayout.razor.cs |
| 135 | +│ └── App.razor |
| 136 | +├── Models/ |
| 137 | +│ ├── Model1.Context.cs # EF Core DbContext (fixed) |
| 138 | +│ ├── *.cs # Entity models |
| 139 | +├── Program.cs # Generated by Layer 2 |
| 140 | +├── ContosoUniversity.csproj # With project reference to BWFC |
| 141 | +├── layer2-manual-items.md |
| 142 | +├── layer2-transforms.log |
| 143 | +└── scaffold-command.txt |
| 144 | +``` |
0 commit comments