Open
Description
In the following:
public class MyContext : DbContext
{
public required DbSet<Blog> Blogs { get; set; }
}
It's common for users to use required
, since the property is non-nullable and uninitialized: in normal circumstances, such a property triggers a warning for an uninitialized NRT property. However, EF comes with a diagnostics suppressor that removes the NRT warning, and the required
just gets in the way: you can't simply initialize MyContext (you must also initialize Blogs), although the DbContext constructor takes care of injecting the property.
In other words, we have a pit of failure here... We should issue a warning for this case, with a code fix to remove the required
.
/cc @DamianEdwards @davidfowl @AndriySvyryd, as discussed offline.