Skip to content

Support EF Core OwnsOne().ToJson() JSON column mapping#233

Merged
jeremydmiller merged 1 commit intomasterfrom
issue-232-efcore-tojson-support
Mar 28, 2026
Merged

Support EF Core OwnsOne().ToJson() JSON column mapping#233
jeremydmiller merged 1 commit intomasterfrom
issue-232-efcore-tojson-support

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

  • Fixes Ef Core JSON backed complex properties ignored by Marten schema migrations #232: EF Core entities using OwnsOne().ToJson() had their JSON columns silently ignored during Weasel schema migrations
  • MapToTable() now iterates entity navigations to detect owned types mapped to JSON via IsMappedToJson(), and adds the container column (via GetContainerColumnName() / GetContainerColumnType()) to the table definition
  • Defaults to jsonb column type when no explicit container column type is specified by EF Core

Test plan

  • New test: verifies JSON column appears in mapped table (should_map_json_column_from_owned_entity_with_to_json)
  • New test: verifies JSON column type is jsonb (json_column_should_be_jsonb_type)
  • New test: full migration round-trip with JSON data (can_apply_migration_with_json_column)
  • Verify existing EF Core tests still pass (pre-existing PK casing failures are unrelated)

🤖 Generated with Claude Code

MapToTable now detects owned entity types mapped to JSON via ToJson()
and adds the container column to the Weasel table definition. Previously
these columns were silently ignored because only scalar IProperty values
were enumerated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 15cccf2 into master Mar 28, 2026
21 checks passed
@jeremydmiller jeremydmiller deleted the issue-232-efcore-tojson-support branch March 28, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ef Core JSON backed complex properties ignored by Marten schema migrations

1 participant