How to use C# 8.0 Nullable Reference Types with Entity Framework Core models?

There is no proper way to handle non-nullable navigational properties.

  1. Documentation suggests two ways and both are not type safe. Use a
    backing field and throw InvalidOperationException. It is unclear how
    it differs from doing nothing and have a NullReferenceException
  2. Suppress it with null forgiving operator

Official documentation link:

Leave a Comment