Skip to content

Investigation: EF Core 10 FieldValues property type change and JSON mapping strategies#342

Merged
christiannagel merged 4 commits intomainfrom
copilot/assess-fieldvalues-property-change
Oct 16, 2025
Merged

Investigation: EF Core 10 FieldValues property type change and JSON mapping strategies#342
christiannagel merged 4 commits intomainfrom
copilot/assess-fieldvalues-property-change

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 15, 2025

Overview

This PR provides a comprehensive investigation and documentation for issue #340 regarding the impact assessment and mapping strategies for changing the FieldValues property type from IDictionary<string, IEnumerable<string>> to Dictionary<string, string[]> in the Game class.

Problem Statement

The current FieldValues property uses IDictionary<string, IEnumerable<string>>, which requires custom converters in all database providers. With EF Core 10 and SQL Server 2025 promising improved JSON support, we need to assess:

  1. What needs to change if we update the property type to Dictionary<string, string[]>
  2. Whether EF Core 10 allows keeping the interface type while mapping to concrete types for database storage
  3. The impact on serialization, converters, and database interoperability

Investigation Results

Documentation Delivered

This PR adds four comprehensive documentation files (2,300+ lines, 77KB total) to the /docs directory:

  1. EFCore10-FieldValues-Investigation.md (33KB)

    • Complete technical analysis of current implementation across all 3 database providers
    • Detailed impact assessment showing 13+ files affected
    • EF Core 9 vs EF Core 10 comparison
    • Three mapping strategy options with pros/cons
    • Database migration considerations and testing strategy
  2. POC-FieldValues-TypeChange.md (28KB)

    • Proof-of-concept with complete working code samples
    • Before/after comparisons for all affected files
    • Updated configurations for SQL Server, PostgreSQL, and Cosmos DB
    • Factory methods, test updates, and client modifications
    • Backward compatibility patterns
  3. README-FieldValues-Investigation.md (8KB)

    • Executive summary with quick reference tables
    • Decision matrix and FAQs
    • Recommended next steps
  4. ISSUE-340-INVESTIGATION-SUMMARY.md (8KB)

    • Ready-to-post GitHub issue comment with all findings

Key Findings

Impact Scope:

  • 13+ files require updates across model, database, factory, client, and test layers
  • Breaking change but manageable with clear migration path
  • No database migration required - existing string storage format remains compatible
  • Moderate complexity - primarily type signature and converter updates

Current State:

  • Repository uses EF Core 9.0.9 (not 10.x yet)
  • Custom converters work well with current type
  • Three database providers use different approaches: SQL Server and PostgreSQL use string format, Cosmos DB uses JSON

Storage Format Analysis:

// Current storage in SQL Server/PostgreSQL (string format)
"colors:Red#colors:Green#colors:Blue#shapes:Circle"

// Current storage in Cosmos DB (JSON)
{
  "colors": ["Red", "Green", "Blue"],
  "shapes": ["Circle", "Square"]
}

Both formats work identically with either property type - no migration needed.

Mapping Strategy Options

Option 1: Direct Property Type Change ⭐ (Recommended for v4.0.0)

// Change from:
public required IDictionary<string, IEnumerable<string>> FieldValues { get; init; }

// To:
public required Dictionary<string, string[]> FieldValues { get; init; }

Pros: Clean implementation, better performance, aligns with EF Core capabilities
Cons: Breaking change requiring major version bump

Option 2: Interface with Explicit Implementation (Not recommended)
Maintains backward compatibility but adds complexity without clear benefit.

Option 3: Wait for EF Core 10 ⭐ (Current recommendation)
Test EF Core 10 capabilities before making breaking changes.

Recommendations

Immediate Action

Documentation complete - This PR provides all necessary information for decision-making

Short-term (When EF Core 10 Preview Available)

  • Test EF Core 10 preview packages
  • Validate actual JSON support capabilities
  • Measure query performance improvements
  • Update documentation based on findings

Long-term (Version 4.0.0 Planning)

  • Implement property type change
  • Update all 13+ affected files
  • Create migration guide for consumers
  • Release as major version 4.0.0

Final Recommendation

⭐ Wait for EF Core 10 stable release, then implement in version 4.0.0

Rationale:

  • EF Core 10 is not yet released (currently using 9.0.9)
  • Current implementation with custom converters works well
  • Should validate EF Core 10's actual capabilities before making breaking changes
  • Breaking change is appropriate for a major version bump
  • No urgent need to change now

Migration Path for Consumers

When implemented in v4.0.0, the change is backward-compatible for most usage patterns since arrays implement IEnumerable<string>:

// Existing code continues to work
IEnumerable<string> colors = game.FieldValues["colors"];
foreach (var color in colors) { /* ... */ }
bool hasRed = colors.Contains("Red");

// New code can use array-specific features
int count = game.FieldValues["colors"].Length; // More efficient than .Count()
string firstColor = game.FieldValues["colors"][0]; // Direct indexing

What This PR Does NOT Include

This is an investigation and documentation only PR. It does not implement the type change or modify any production code. The actual implementation should be done in a future PR for version 4.0.0 after EF Core 10 is available and tested.

Related

Original prompt

This section details on the original issue you should resolve

<issue_title>Assess impacts and mapping strategies for FieldValues property type change and EF Core 10 JSON features</issue_title>
<issue_description>This issue investigates two main areas related to EF Core 10 and SQL Server 2025 JSON support, as a sub-issue of #340:

  1. Impact Assessment of Property Change:

    • Check what needs to be changed when updating the FieldValues property from IDictionary<string, IEnumerable<string>> to Dictionary<string, string[]> in the Game class.
    • Identify code locations, serialization/deserialization logic, converters, and any usages affected by this breaking change.
  2. Mapping Strategy Verification:

    • Verify if EF Core 10 with SQL Server 2025 JSON column support allows keeping IDictionary<string, IEnumerable<string>> in the class, but mapping it to Dictionary<string, string[]> for database storage.
    • Explore possible mapping configurations, custom converters, or value comparisons to leverage new JSON features while retaining flexibility in the domain model.
  3. Documentation:

    • Document findings including code samples, migration steps, limitations, and recommendations for both approaches.
    • Highlight any remaining gaps in queryability or compatibility, especially regarding usage patterns and database interoperability.

References:

Please provide a clear summary of what needs to be changed, possible mapping strategies, and the results of your investigation.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #341


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 15, 2025 20:44
…ange

Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
Copilot AI changed the title [WIP] Assess impacts and mapping strategies for FieldValues property type change Investigation: EF Core 10 FieldValues property type change and JSON mapping strategies Oct 15, 2025
Copilot AI requested a review from christiannagel October 15, 2025 20:52
@christiannagel christiannagel marked this pull request as ready for review October 16, 2025 15:07
@christiannagel christiannagel merged commit 1ce5b08 into main Oct 16, 2025
3 checks passed
@christiannagel christiannagel deleted the copilot/assess-fieldvalues-property-change branch October 16, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants