Skip to content

Commit

Permalink
Update entity-framework/core/modeling/required-optional.md
Browse files Browse the repository at this point in the history
Co-Authored-By: Diego Vega <[email protected]>
  • Loading branch information
roji and divega authored Sep 16, 2019
1 parent 323641a commit 1af7710
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion entity-framework/core/modeling/required-optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ By convention, a property whose CLR type can contain null will be configured as

C# 8 introduced a new feature called [nullable reference types](/dotnet/csharp/tutorials/nullable-reference-types), which allows reference types to be annotated, indicating whether it is valid for them to contain null or not. This feature is disabled by default, and if enabled, it modifies EF Core's behavior in the following way:

* If nullable reference types are disabled (the default), all properties with CLR reference types are configured as required by convention (e.g. `string`).
* If nullable reference types are disabled (the default), all properties with CLR reference types are configured as optional by convention (e.g. `string`).
* If nullable reference types are enabled, properties will be configured based on the C# nullability of their CLR type: `string?` will be configured as optional, whereas `string` will be configured as required.

Using nullable reference types is recommended since it flows the nullability expressed in C# code to EF Core's model and to the database, and obviates the use of the Fluent API or Data Annotations to express the same concept twice.
Expand Down

0 comments on commit 1af7710

Please sign in to comment.