Fix bulk insert for EF Core JSON complex collections (ComplexCollection.ToJson)#107
Draft
Copilot wants to merge 4 commits into
Draft
Fix bulk insert for EF Core JSON complex collections (ComplexCollection.ToJson)#107Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix PhenX bulk insert for EF Core JSON complex collection
Fix bulk insert for EF Core JSON complex collections (ComplexCollection.ToJson)
Jun 9, 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.
Bulk inserting entities with
ComplexCollection(...).ToJson()mappings failed withArgumentException: Property 'X' is not defined for type 'List<T>'becauseTableMetadata.GetColumnstried to expand the element-type sub-properties onto the collection type.Core fix
TableMetadata.GetColumnsnow detects JSON-mapped complex properties via theRelational:ContainerColumnNameEF Core annotation and emits a singleColumnMetadatafor the whole JSON column instead of expanding sub-properties.ColumnMetadatagains a second constructor for JSON complex properties that serializes the collection withSystem.Text.Jsondefault options (PascalCase — matching EF Core's storage format).Propertyis nowIProperty?.Provider fixes
GetPostgreSqlTypeguardscolumn.Property != null; falls back to parsingStoreDefinitionto resolveNpgsqlDbType.Jsonb/NpgsqlDbType.Json.GetSqliteTypeguardscolumn.Property != null; falls back toStoreDefinitionprefix for the store type.Tests
Added
TestEntityWithJsonComplexCollectionand anInsertsEntities_WithJsonComplexCollectiontest covering both null and non-null JSON collections.InsertReturn/InsertReturnAsyncstrategies are skipped on SQLite — EF Core requires composing JSON path expressions over the result, which is incompatible with a rawINSERT...RETURNINGstatement.