Entity Framework Core (7): load single entity by id
<p><code>.ToListAsync</code> is used to get a collection of items from DB in EF Core. That's clear. But what is the right way to get single item? In async way if possible.</p>

<pre><code>public async static Task&lt;Source&gt; LoadEntityAsync(int sourceID)
{
    using (var db = new RPDBContext())
    {
        var sources =
            await
                db.Source
                    .Where(x =&gt; x.SourceID == sourceID)
                    .ToListAsync();
        // TODO that's like a hack:
        return sources.First();
    }
}
</code></pre>