Skip to content

test: spike B, design time without .targets from a packed consumer - #39

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
spike/17-design-time-no-targets
Nov 11, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
spike/17-design-time-no-targets

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #17

Problem

The plan drops the .targets-injected DesignTimeServicesReferenceAttribute and wires SchemaKit through UseSchemaKit() alone. That rested on reading DesignTimeServicesBuilder in EF Core's source, never on a packed consumer. In 5.x the .targets were the delivery mechanism, and a migration that scaffolded without them was the failure hardest to see. Spike B is the second of the two spikes that must pass before any public API is written.

Change

  • spikes/B.DesignTime (throwaway): spike A's kit as a package (SpikeKit.Package/, no build/ folder), a consumer copied outside the repository in three variants (parameterless constructor, IDesignTimeDbContextFactory, a host with AddDbContext), and run.sh, which restores through a private package cache and source mapping and drives dotnet-ef 11.0.0-rc.3 and the application.
  • spikes/A.DecoratorOwnership/SpikeKit/Decorators.cs: the differ emits a real CREATE INDEX and DROP INDEX, ended with the provider's statement terminator, so a path is judged by the catalog.
  • design/schemakit-core-plan.md: design time measured (3.2), the compiled-model residual corrected (3.2), the terminator rule (3.8), scripts applied and not only read (4), both spikes passed (6, 8).
  • .github/workflows/dotnet.yml: the Spikes lane gets a PostgreSQL 18 service and runs spikes/*/run.sh, writing each table to the job summary.

What it answers

Question of #17 Answer
Does every design-time path get the context's differ, with no .targets? Yes: migrations add, has-pending-model-changes, migrations script with and without --idempotent, database update, a bundle, dbcontext optimize, in all three variants
Do the runtime paths agree? Yes: EnsureCreated(), GenerateCreateScript(), Migrate(). The databases hold both indexes on SQLite and PostgreSQL 18
Is a change only the kit can see noticed? has-pending-model-changes reports it and Migrate() refuses with PendingModelChangesWarning
What if the kit is left out? migrations add is refused at the declaration and writes nothing, also when only the design-time factory forgets it

Found beyond the question:

  • A statement without a terminator passes every path but the scripts. database update, the bundle and Migrate() accepted it; both generated scripts failed to apply (42601). A check of the script's text was green throughout.
  • A compiled model without the kit is loud at EnsureCreated() and Migrate(), because EF builds the design-time model from OnModelCreating. The plan had it as a silent residual.
  • A user's own IDesignTimeServices differ is silent, as the plan says: the migration scaffolds without the index and the snapshot hides it from every later diff. It doubles as the control for the content checks.

Tests

  • 62 paths as expected, 0 failed; spike A's 69 conditions still pass with the changed differ.
  • The script-application rows failed before the terminator fix (syntax error at or near "INSERT", and "END" for the idempotent script) and pass after it.
  • Run locally on SDK 11.0.100-rc.1 in a scratch copy, with PostgreSQL 18 in a container. This PR's Spikes lane is the run on SDK 11.0.100.
  • Not covered: SQL Server with a live database, statements that cannot run in a transaction (spike D, Spike D: SqlOperations in idempotent scripts and bundles #19), a separate migrations assembly or startup project.

🤖 Generated with Claude Code

Answers #17: a package with no build/ folder gets every design-time and runtime path
through UseSpikeKit() on the context's options alone. 62 paths on SQLite, Npgsql and
SQL Server, with a parameterless constructor, an IDesignTimeDbContextFactory and a
host, judged by scaffolded content or by what the database holds.

- spikes/B.DesignTime: spike A's kit packed, a consumer copied outside the repository,
  and run.sh, which drives dotnet-ef 11.0.0-rc.3 through migrations add,
  has-pending-model-changes, script, script --idempotent, database update, a bundle
  and dbcontext optimize, and the application through EnsureCreated(),
  GenerateCreateScript() and Migrate().
- The spike differ now emits a real CREATE INDEX, ended with the provider's statement
  terminator. Without the terminator every path passed except the scripts, which did
  not apply; the rows that apply them were added for it and failed before the fix.
- A compiled model without the kit is loud at EnsureCreated() and Migrate(): EF builds
  the design-time model from OnModelCreating. A user's own IDesignTimeServices differ
  stays silent, as the plan says.
- The plan records all of it (sections 3.2, 3.8, 4, 6, 8); the Spikes lane gets a
  PostgreSQL service and runs spike scripts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 11, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring area/release Versioning, changelogs, release wiring labels Nov 11, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 6add93b into main Nov 11, 2026
5 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the spike/17-design-time-no-targets branch November 11, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring area/release Versioning, changelogs, release wiring package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spike B: design time without .targets, from a packed consumer

1 participant