Should EntityEntry's Expression-based parameters be nullable-friendly?
See original GitHub issueHi guys,
With EF Core 6.0 adopting nullable annotations pretty much everywhere, we now have a great coverage (thanks for that!).
I’m currently testing my OpenIddict framework on the latest .NET 6.0 preview and I’m now seeing a few warnings caused by things like Context.Entry(authorization).Reference(entry => entry.Application)
when the referenced navigation property is nullable, which requires using a null-forgiving operator to fix them (e.g Context.Entry(authorization).Reference(entry => entry.Application!)
).
My question/demand is simple: is it the expected behavior or will the methods taking an expression accessor be updated at some point to allow referencing nullable navigation properties without triggering warnings?
/cc @roji as I believe you’ve taken care of most of the “add nullable annotations everywhere” tasks 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
There’s also the possibility of constraining TProperty to
class?
instead ofclass
, but that would flow through to the ReferenceEntry’s generic type as well, so we’d need to look a bit wider at how it all works together…@kevinchalet thanks for raising this - it seems to be a case of incorrect annotation.
Null-annotating the entire EF Core codebase is a massive task, and we’re bound to have made some mistakes - so I wouldn’t assume that any weirdness you’re seeing is by-design. Please don’t hesitate to flag such issues to us as you’ve done here.
@smitpatel I think you did most of change tracking, are you interested in taking a look? If not let me know.