Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

Description

Non-string discriminators with the default name "Discriminator" caused spurious migrations on every scaffold because the snapshot omitted the type argument:

// Before (loses type info, defaults to string on read-back)
b.HasDiscriminator().HasValue(0);

// After (preserves int type)
b.HasDiscriminator<int>("Discriminator").HasValue(0);

Changes

  • CSharpSnapshotGenerator.cs: Removed && discriminatorProperty.Name != "Discriminator" condition from both entity type and complex property discriminator generation
  • Tests: Updated 8 existing baseline tests, added Discriminator_with_non_string_default_name_is_stored_in_snapshot to cover the regression scenario

Fixes #37143

Original prompt

Fix #37143 by always generating a HasDiscriminator call with generic type argument and property name in the snapshot.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix snapshot to always generate HasDiscriminator call Fix #37143: Always generate HasDiscriminator with type argument and property name in snapshot Nov 26, 2025
Copilot finished work on behalf of AndriySvyryd November 26, 2025 02:04
Copilot AI requested a review from AndriySvyryd November 26, 2025 02:04
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.

2 participants