Efcore: Nullable Reference Type for FirstOrDefaultAsync

Created on 31 Dec 2019  路  4Comments  路  Source: dotnet/efcore

My project has nullable reference types enabled and the following code has the warning CS8619 Nullability of reference types in value of type 'Task' doesn't match target type 'Task'.

image

FirstOrDefaultAsync can return null and shouldn't FirstOrDefaultAsync return Task ?

Further technical details

EF Core version: 3.1.0
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL 3.1.0
Target framework: .NET Core 3.1
Operating system: Windows 10
IDE: Visual Studio 2019 16.4.2

closed-duplicate customer-reported

Most helpful comment

Yeah, we need to annotate our async LINQ extensions for nullability - this is part of #19007. We can close this as a duplicate of that, although there may be value in keeping this open as it's a particularly visible area of the API. Note that System.Linq has already been annotated, so we should be following that (although async may make that a bit challenging).

Is there a master issue tracking issues relating to non-nullable reference types, or is there a document containing known issues or limitations?

There's the Nullable Reference Types doc page which contains most information NRTs, I'll add a note about this current limitation.

All 4 comments

@roji Thoughts?

Is there a master issue tracking issues relating to non-nullable reference types, or is there a document containing known issues or limitations? We're seeing some nullability confusion regarding the values passed in to linq functors or as return values from linq expressions.

Yeah, we need to annotate our async LINQ extensions for nullability - this is part of #19007. We can close this as a duplicate of that, although there may be value in keeping this open as it's a particularly visible area of the API. Note that System.Linq has already been annotated, so we should be following that (although async may make that a bit challenging).

Is there a master issue tracking issues relating to non-nullable reference types, or is there a document containing known issues or limitations?

There's the Nullable Reference Types doc page which contains most information NRTs, I'll add a note about this current limitation.

Was this page helpful?
0 / 5 - 0 ratings