How to Enable Nullable Reference Types in Entity Developer Models

How to Enable Nullable Reference Types in Entity Developer Models

This article is for dotConnect providers with ORM support (all except Universal and SQL Server).

When generating C# entity classes with Entity Developer, properties may appear as non-nullable even though nullable reference types are expected. This applies to projects using EF Core, EF6, or NHibernate with dotConnect providers that support ORM.

Solution

Entity Developer templates for EF Core, Entity Framework 6, and NHibernate support Nullable Reference Types. The Nullable Reference Types option controls when C# 8 nullable and non-nullable reference types are generated:
  1. Enable — nullable annotation context is enabled.
  2. Disable — #nullable disable directives are generated.
  3. Default — pre-C# 8.0 classic behavior is used.

Set the option: Nullable Reference Types = Enable.


With this setting, the generated fields will be nullable: