Fix FetchForWriting with natural keys without explicit projection registration#4213
Merged
jeremydmiller merged 2 commits intomasterfrom Mar 28, 2026
Merged
Conversation
…istration When using FetchForWriting<TDoc, TId> with a natural key type and no explicit Projections.Snapshot<TDoc>(Inline) call, Marten now: 1. Auto-registers the snapshot projection on first FetchForWriting call 2. Resets schema existence checks so the natural key table gets created 3. At startup, scans for [NaturalKeyAggregate] attributes emitted by the JasperFx.Events source generator to pre-register projections This fixes the Npgsql.PostgresException: '42P01: relation "public.mt_natural_key_..." does not exist' error reported in #4199. Closes #4199 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- JasperFx 1.21.4 → 1.21.5 - JasperFx.Events 1.24.1 → 1.24.2 (NaturalKeyAggregateAttribute) - JasperFx.Events.SourceGenerator 1.3.0 → 1.4.0 (natural key discovery) - Microsoft.Extensions.Hosting.Abstractions 8.0.0 → 8.0.1 (transitive dep) - Microsoft.Extensions.Diagnostics.HealthChecks 8.0.0 → 8.0.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Npgsql.PostgresException: '42P01: relation "public.mt_natural_key_..." does not exist'when usingFetchForWriting<TDoc, TNaturalKey>()without explicitly registeringProjections.Snapshot<TDoc>(Inline)[NaturalKeyAggregate]attributes emitted by JasperFx.Events.SourceGenerator 1.4.0 to pre-register projections at startupCloses #4199
Depends on JasperFx/jasperfx#172
Test plan
nuke compile🤖 Generated with Claude Code