Wiring
Page 4 of 8 · Two exercises

A new feature touches the same 9 files, but only 1 shared one

Shared files edited went from 3 to 1, and a merge of two features had 0 conflicts instead of 2.

Exercise 1

Adding one feature touches the same 9 files, but only 1 shared one

The feature is Quote: a table and an endpoint that counts quotes. It was added to both copies, then each copy was built, migrated and started; the endpoint answered 0, then 2 after two rows were inserted Measured.

The grid lists every file the feature touched; shared files have a pink row:

File
By hand
Generated
Domain/Quote/Repository.cs
Quote/Data/QuoteData.cs
Quote/Data/QuoteRepository.cs
Quote/API/V1/QuoteController.cs
Quote/Data/QuoteTables.cs
Quote/QuoteRegistration.cs
Migration + its Designer copy (2 files)
DomainServices.csshared
MainDbContext.csshared
The snapshotshared

By hand

9
files touched
3
shared files edited
2
shared files edited by a person

Generated

9
files touched
1
shared file edited (by EF)
0
shared files edited by a person

Both ways touch 9 files, but by hand a person edits 2 shared lists, and generated a person edits none Measured. The snapshot change is the same 16 lines both ways, written by EF.

Exercise 2

Two features merged: the hand-edited lists caused every conflict but the snapshot's

Branch A adds Quote; branch B, from the same start, adds a second feature; then B is merged into A. The chart counts the files in conflict:

Files in conflict after the merge
  • By hand
  • Generated
Quote + Badge
2 files
0 files
Quote + Quip
3 files
1 file
Show as table
By handGenerated
Quote + Badge20
Quote + Quip31

two merges, measured

Generated wiring removed both hand-edited lists from every conflict Measured.

  • Quote + Badge: by hand, DomainServices.cs and MainDbContext.cs conflicted; generated, nothing did. The snapshot merged by itself both ways.
  • Quote + Quip: these names sort next to each other, so EF writes their parts of the snapshot side by side, and the snapshot conflicted both ways.
  • After the fixes, both copies built, EF reported no pending changes, a fresh database got both tables, and both endpoints answered 200.

The fix for the snapshot conflict on the generated copy is one command:

  1. Take one side
    Keep branch A's snapshot.
  2. Rebuild it
    Build, then run dotnet ef migrations add Regen.
  3. Keep the snapshot only
    Delete the 2 migration files it wrote; keep the rewritten snapshot.

So the snapshot clashes only when two changes land near each other in it Measured.