ln-723-mockdata-migrator
Type: L3 Worker
Category: 7XX Project Bootstrap
Parent: ln-720-structure-migrator
Migrates mock data from ORM schemas to .NET MockData classes with realistic sample data.
Purpose & Scope
| Aspect |
Description |
| Input |
ORM schema files (Drizzle, Prisma, TypeORM) |
| Output |
C# MockData static classes |
| Primary ORM |
Drizzle (others supported) |
Scope boundaries:
- Parses ORM schema definitions
- Generates C# entities and MockData classes
- Creates realistic sample data
- Does not generate database migrations or EF Core configs
Workflow
| Phase |
Name |
Actions |
Output |
| 1 |
Parse Schema |
Read ORM file, extract table definitions |
Entity model |
| 2 |
Map Types |
Apply type mapping rules, detect nullable |
C# type definitions |
| 3 |
Generate MockData |
Create static class, generate sample data |
MockData.cs files |
| 4 |
Verify |
Compile check, relationship validation |
Valid C# code |
Phase 1: Parse Schema
Extract entity definitions from ORM schema.
| Step |
Action |
Reference |
| 1.1 |
Locate schema file(s) |
— |
| 1.2 |
Identify ORM type (Drizzle/Prisma/TypeORM) |
Detect by syntax |
| 1.3 |
Extract table definitions |
drizzle_patterns.md |
| 1.4 |
Extract column definitions |
drizzle_patterns.md |
| 1.5 |
Identify constraints (PK, FK, nullable) |
drizzle_patterns.md |
| 1.6 |
Extract enum definitions |
drizzle_patterns.md |
Output: Entity model with columns, types, and constraints.
Phase 2: Map Types
Convert ORM types to C# types.
| Step |
Action |
Reference |
| 2.1 |
Map column types to C# |
type_mapping.md |
| 2.2 |
Determine nullable status |
type_mapping.md |
| 2.3 |
Identify primary keys |
type_mapping.md |
| 2.4 |
Map foreign keys |
relationship_mapping.md |
| 2.5 |
Transform names (snake_case → PascalCase) |
drizzle_patterns.md |
Type mapping summary:
| ORM Type |
C# Type |
Nullable Rule |
| uuid |
Guid |
No (PK), Depends (FK) |
| varchar |
string |
Check .notNull() |
| integer |
int |
No |
| boolean |
bool |
No |
| timestamp |
DateTime |
Depends |
Phase 3: Generate MockData
Create C# MockData class with sample data.
| Step |
Action |
Reference |
| 3.1 |
Create MockData class |
data_generation.md |
| 3.2 |
Generate GUIDs for entities |
data_generation.md |
| 3.3 |
Generate sample data per field |
data_generation.md |
| 3.4 |
Ensure FK relationships valid |
relationship_mapping.md |
| 3.5 |
Create accessor methods |
data_generation.md |
Generation order by dependency:
| Order |
Entity Type |
Generate After |
| 1 |
Root entities (no FK) |
First |
| 2 |
First-level children |
Parents exist |
| 3 |
Second-level children |
Grandparents exist |
| N |
Deepest children |
All ancestors exist |
Phase 4: Verify
Validate generated code.
| Check |
Method |
Expected |
| Syntax valid |
Compile check |
No errors |
| FKs valid |
Cross-reference |
All FKs point to existing IDs |
| Types correct |
Type analysis |
Proper C# types |
| Names follow convention |
Pattern check |
PascalCase |
Supported ORM Detection
| ORM |
Detection Pattern |
| Drizzle |
pgTable(), mysqlTable(), sqliteTable() |
| Prisma |
model X { syntax |
| TypeORM |
@Entity(), @Column() decorators |
Entity Transformation Rules
| Source |
Target |
Transformation |
| Table name (plural, snake) |
Class name (singular, Pascal) |
user_profiles → UserProfile |
| Column name (snake) |
Property name (Pascal) |
created_at → CreatedAt |
| Enum name |
Enum type (Pascal) |
status_enum → StatusEnum |
| FK column |
Navigation property |
user_id → UserId |
MockData Class Structure
| Component |
Purpose |
| Private static list |
Holds immutable mock data |
| GetAll() method |
Returns full list as IEnumerable |
| GetById(Guid id) |
Finds single entity by ID |
| GetBy{FK}Id(Guid id) |
Filters by foreign key |
Sample Data Guidelines
| Field Type |
Sample Count |
Distribution |
| Root entities |
3-5 items |
Varied status/priority |
| Child entities |
5-10 items |
Distributed across parents |
| Leaf entities |
10-20 items |
Realistic variety |
Critical Rules
- Single Responsibility: Generate only MockData, no database code
- Idempotent: Can re-run to regenerate
- Valid Relationships: All FKs must reference existing parent IDs
- Realistic Data: Use domain-appropriate values, not random strings
- Generation Order: Parents before children
- Consistent GUIDs: Use fixed GUIDs for reproducibility
Definition of Done
Risk Mitigation
| Risk |
Detection |
Mitigation |
| Parse failure |
Exception during parse |
Support multiple schema formats |
| Invalid type mapping |
Unknown ORM type |
Log warning, use string as fallback |
| FK mismatch |
FK references non-existent ID |
Generate parents first, validate after |
| Name collision |
Duplicate class names |
Prefix with feature name |
| Circular references |
Self-referencing with cycles |
Limit depth, validate graph |
Reference Files
| File |
Purpose |
references/type_mapping.md |
ORM to C# type conversion rules |
references/drizzle_patterns.md |
Drizzle schema parsing patterns |
references/data_generation.md |
Realistic sample data patterns |
references/relationship_mapping.md |
FK handling and generation order |
Version: 2.0.0
Last Updated: 2026-01-10
1---2name: ln-723-mockdata-migrator3description: Migrates mock data from Drizzle ORM schemas to C# MockData classes4---5
6# ln-723-mockdata-migrator
7
8**Type:** L3 Worker
9**Category:** 7XX Project Bootstrap
10**Parent:** ln-720-structure-migrator
11
12Migrates mock data from ORM schemas to .NET MockData classes with realistic sample data.
13
14---
15
16## Purpose & Scope
17
18| Aspect | Description |
19|--------|-------------|
20| **Input** | ORM schema files (Drizzle, Prisma, TypeORM) |
21| **Output** | C# MockData static classes |
22| **Primary ORM** | Drizzle (others supported) |
23
24**Scope boundaries:**
25- Parses ORM schema definitions
26- Generates C# entities and MockData classes
27- Creates realistic sample data
28- Does not generate database migrations or EF Core configs
29
30---
31
32## Workflow
33
34| Phase | Name | Actions | Output |
35|-------|------|---------|--------|
36| 1 | Parse Schema | Read ORM file, extract table definitions | Entity model |
37| 2 | Map Types | Apply type mapping rules, detect nullable | C# type definitions |
38| 3 | Generate MockData | Create static class, generate sample data | MockData.cs files |
39| 4 | Verify | Compile check, relationship validation | Valid C# code |
40
41---
42
43## Phase 1: Parse Schema
44
45Extract entity definitions from ORM schema.
46
47| Step | Action | Reference |
48|------|--------|-----------|
49| 1.1 | Locate schema file(s) | — |
50| 1.2 | Identify ORM type (Drizzle/Prisma/TypeORM) | Detect by syntax |
51| 1.3 | Extract table definitions | `drizzle_patterns.md` |
52| 1.4 | Extract column definitions | `drizzle_patterns.md` |
53| 1.5 | Identify constraints (PK, FK, nullable) | `drizzle_patterns.md` |
54| 1.6 | Extract enum definitions | `drizzle_patterns.md` |
55
56**Output:** Entity model with columns, types, and constraints.
57
58---
59
60## Phase 2: Map Types
61
62Convert ORM types to C# types.
63
64| Step | Action | Reference |
65|------|--------|-----------|
66| 2.1 | Map column types to C# | `type_mapping.md` |
67| 2.2 | Determine nullable status | `type_mapping.md` |
68| 2.3 | Identify primary keys | `type_mapping.md` |
69| 2.4 | Map foreign keys | `relationship_mapping.md` |
70| 2.5 | Transform names (snake_case → PascalCase) | `drizzle_patterns.md` |
71
72**Type mapping summary:**
73
74| ORM Type | C# Type | Nullable Rule |
75|----------|---------|---------------|
76| uuid | Guid | No (PK), Depends (FK) |
77| varchar | string | Check .notNull() |
78| integer | int | No |
79| boolean | bool | No |
80| timestamp | DateTime | Depends |
81
82---
83
84## Phase 3: Generate MockData
85
86Create C# MockData class with sample data.
87
88| Step | Action | Reference |
89|------|--------|-----------|
90| 3.1 | Create MockData class | `data_generation.md` |
91| 3.2 | Generate GUIDs for entities | `data_generation.md` |
92| 3.3 | Generate sample data per field | `data_generation.md` |
93| 3.4 | Ensure FK relationships valid | `relationship_mapping.md` |
94| 3.5 | Create accessor methods | `data_generation.md` |
95
96**Generation order by dependency:**
97
98| Order | Entity Type | Generate After |
99|-------|-------------|----------------|
100| 1 | Root entities (no FK) | First |
101| 2 | First-level children | Parents exist |
102| 3 | Second-level children | Grandparents exist |
103| N | Deepest children | All ancestors exist |
104
105---
106
107## Phase 4: Verify
108
109Validate generated code.
110
111| Check | Method | Expected |
112|-------|--------|----------|
113| Syntax valid | Compile check | No errors |
114| FKs valid | Cross-reference | All FKs point to existing IDs |
115| Types correct | Type analysis | Proper C# types |
116| Names follow convention | Pattern check | PascalCase |
117
118---
119
120## Supported ORM Detection
121
122| ORM | Detection Pattern |
123|-----|-------------------|
124| Drizzle | `pgTable()`, `mysqlTable()`, `sqliteTable()` |
125| Prisma | `model X {` syntax |
126| TypeORM | `@Entity()`, `@Column()` decorators |
127
128---
129
130## Entity Transformation Rules
131
132| Source | Target | Transformation |
133|--------|--------|----------------|
134| Table name (plural, snake) | Class name (singular, Pascal) | `user_profiles` → `UserProfile` |
135| Column name (snake) | Property name (Pascal) | `created_at` → `CreatedAt` |
136| Enum name | Enum type (Pascal) | `status_enum` → `StatusEnum` |
137| FK column | Navigation property | `user_id` → `UserId` |
138
139---
140
141## MockData Class Structure
142
143| Component | Purpose |
144|-----------|---------|
145| Private static list | Holds immutable mock data |
146| GetAll() method | Returns full list as IEnumerable |
147| GetById(Guid id) | Finds single entity by ID |
148| GetBy{FK}Id(Guid id) | Filters by foreign key |
149
150---
151
152## Sample Data Guidelines
153
154| Field Type | Sample Count | Distribution |
155|------------|--------------|--------------|
156| Root entities | 3-5 items | Varied status/priority |
157| Child entities | 5-10 items | Distributed across parents |
158| Leaf entities | 10-20 items | Realistic variety |
159
160---
161
162## Critical Rules
163
164- **Single Responsibility:** Generate only MockData, no database code
165- **Idempotent:** Can re-run to regenerate
166- **Valid Relationships:** All FKs must reference existing parent IDs
167- **Realistic Data:** Use domain-appropriate values, not random strings
168- **Generation Order:** Parents before children
169- **Consistent GUIDs:** Use fixed GUIDs for reproducibility
170
171---
172
173## Definition of Done
174
175- [ ] Schema file parsed successfully
176- [ ] All tables/entities extracted
177- [ ] Type mappings applied correctly
178- [ ] MockData class generated per feature/entity group
179- [ ] Sample data includes 5-10 items per entity
180- [ ] Foreign keys reference valid parent IDs
181- [ ] Accessor methods generated (GetAll, GetById)
182- [ ] Code compiles without errors
183
184---
185
186## Risk Mitigation
187
188| Risk | Detection | Mitigation |
189|------|-----------|------------|
190| Parse failure | Exception during parse | Support multiple schema formats |
191| Invalid type mapping | Unknown ORM type | Log warning, use string as fallback |
192| FK mismatch | FK references non-existent ID | Generate parents first, validate after |
193| Name collision | Duplicate class names | Prefix with feature name |
194| Circular references | Self-referencing with cycles | Limit depth, validate graph |
195
196---
197
198## Reference Files
199
200| File | Purpose |
201|------|---------|
202| `references/type_mapping.md` | ORM to C# type conversion rules |
203| `references/drizzle_patterns.md` | Drizzle schema parsing patterns |
204| `references/data_generation.md` | Realistic sample data patterns |
205| `references/relationship_mapping.md` | FK handling and generation order |
206
207---
208
209**Version:** 2.0.0
210**Last Updated:** 2026-01-10