Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

AndriySvyryd
Copy link
Member

@AndriySvyryd AndriySvyryd commented Dec 19, 2024

Fixes #34996
Port of #35020

Description

NonNullableConventionBase convention adds an annotation to the model containing a cached NullabilityInfoContext to be used during model building. Usually, it's removed before the model is finalized, but in certain cases another convention can request it during finalization after the cache is removed causing the annotation to be added back to the model.

Customer impact

An exception is thrown when adding a new migration or a compiled model for affected models (mostly with types containing a field that's a primitive collection). There is workaround via model configuration, but it's usually not practical because the exception doesn't provide any clues on what property caused it:

System.InvalidOperationException: Cannot scaffold C# literals of type 'System.Reflection.NullabilityInfoContext'. The provider should implement CoreTypeMapping.GenerateCodeLiteral to support using it at design time.

How found

Multiple customer reports on 8 and 9.

Regression

Yes, from 7, but started affecting even more models in 9.

Testing

Test added

Risk

Low.

This means it gets correctly filtered out when using the model for code generation, and hence we don't try to generate a literal for it.

Fixes #34996
@maumar
Copy link
Contributor

maumar commented Jan 6, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AndriySvyryd AndriySvyryd merged commit cc16006 into release/9.0-staging Jan 7, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the Issue34996 branch January 7, 2025 18:22
This was referenced Jul 22, 2025
This was referenced Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants