[release/8.0] Don't generate a discriminator in the snapshot if there's no discriminator property.#33622
Merged
maumar merged 1 commit intorelease/8.0from May 1, 2024
Merged
[release/8.0] Don't generate a discriminator in the snapshot if there's no discriminator property.#33622maumar merged 1 commit intorelease/8.0from
maumar merged 1 commit intorelease/8.0from
Conversation
…nator property. Fixes #33605
258c27b to
f08ecf3
Compare
ajcvickers
approved these changes
Apr 30, 2024
Member
|
Approved in email. |
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.
Fixes #33605
Description
When an entity type is discovered as part of a TPH inheritance it gets a discriminator value assigned. If the base type is ignored later and a migration is generated EF preserves the discriminator value even though the is no corresponding discriminator property.
Customer impact
When adding another migration in the above scenario EF will generate an operation to drop the non-existing discriminator column, resulting in an error. A workaround is to manually edit the snapshot or the migration, but this would need to be done after every new migration.
While there has only been one report this affects models with an abstract unmapped base type, which is not that uncommon.
How found
Customer reported on 8.
Regression
Yes, from 7
Testing
Test added.
Risk
Low. The fix is in code that only runs as part of a design-time tool.