Description
In Entity Framework, enabling nullable reference types feature without code modifications will change the behavior.
Without NRT: any reference type property maps to be optional in the database, unless the RequiredAttribute is explicitly added.
With NRT: any reference type property maps to be required in the database, unless it's marked with nullable annotation.
The article gives an impression that enabling NRT will never change the runtime behavior.
I'm not sure how entity framework knows under the hoods if the property is marked with nullable annotation or not, (maybe reflection?). But anyways, the explanation about this point shouldn't be EF-specific, but to whatever technique that is used to determine the nullability at runtime, and EF may be just taken as an example.
Although this is not the common case, and is actually rare, but I think worth noting.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 0dfe2629-7f0f-5ab7-6bf3-af84b050c425
- Version Independent ID: 17533d4f-fae1-0883-8838-4ba7c0727bc7
- Content: Upgrade to nullable reference types
- Content Source: docs/csharp/tutorials/upgrade-to-nullable-references.md
- Product: dotnet-csharp
- Technology: csharp-null-safety
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
Metadata
Metadata
Assignees
Labels
Type
Projects
Status