.NET
Possible, and the biggest change of the four. The layer projects and the solution file go. Each context becomes its own project.
The files
Explorer
- all.projfinds projects by pattern; no solution file
- Kernel.csprojthe app
- what every context may use
- the layer check, runs in the build
- Directory.Build.propsnames and references come from the folder
- context.yaml
- orders.Contract.csproj
- orders.csprojone line
- Context.csthe one registration
- policies.yaml
- flags.yaml
The boundaries hold
planted breaches (real output, shortened)
$dotnet build contexts/billing/src/billing.csproj
error CS0234: The type or namespace name 'Orders' does not exist in the namespace 'Ctx' (are you missing an assembly reference?)
$
1 / 2
.NET in detail, on real alcohol.zinc
Two modules were moved into their own projects: Causes (a leaf) and NfcTag (tangled). MEASURED
| Check | Result |
|---|---|
| Build | 0 errors |
| Unit tests | the same 333 names; the same 9 that failed before still fail |
| Database model | byte-identical SQL; no pending migration |
| Files | 164 touched: 109 pure moves, 55 changed |
| Generated registration | no reflection scan |
| Clean build before the move | 18 to 22 s |
| Clean build after the move | 33 s |
- The pain is the real app, not the template. In the code, 19 of 23 modules form one loop (this scan folds HabitVersion and HabitExecution into Habit); .NET refuses loops between projects. The shared DbContext is used 506 times in 35 files. MEASURED
- Your model costs build time: 25 contexts as projects build in 77 seconds from clean, against 13 seconds as one project. One edit costs about the same (10 against 9 seconds). MEASURED
- I keep projects. They are your model, and they are what makes the compiler guard each context. Caching and testing only the changed context should win most of it back. REASONED, NOT TESTED
- Moving all of zinc: 1 to 2 weeks, mostly untangling the loop. REASONED
Database models split across projects (EF)
| Question | One DbContext | One DbContext per context |
|---|---|---|
| Model split across projects | works | works |
| Migrations on real Postgres | work | work |
| Two pull requests add neighbouring tables | conflict in the shared snapshot | clean |
| A transaction across contexts | works | needs a shared connection |
| A database link across contexts | works | raw SQL only, invisible to EF |
MEASURED. The design forbids the last two anyway. This is trade-off 2.