ASP.NET Core Select Helper Throws Object Reference not set to an instance of an Object
<p>I've created an ASP.NET Core web application that uses Entity Framework Core to read from my existing database.  I want to populate a select control with a list of FacilityNames in a view to create a new entry in my FacilityRevenue table.</p>

<p>My Create method on the FacilityRevenue Controller is as follows:</p>

<pre><code>public IActionResult Create()
    {
       PopulateFacilityDropDownList();
        return View();
    }

    private void PopulateFacilityDropDownList
    (object selectedFacility = null)
    {
        var facilityQuery = from f in _context.FacilityMaster
                            orderby f.FacilityName
                            select f;
        ViewBag.FacilityID = new SelectList(facilityQuery.AsNoTracking(), "FacilityID", "FacilityName", selectedFacility);
    }
</code></pre>

<p>My Create view includes the following markup:</p>

<pre><code>        &lt;label asp-for="FacilityName" class="col-md-2 control-label"&gt;&lt;/label&gt;
        &lt;div class="col-md-10"&gt;
            &lt;select asp-for="FacilityId" asp-items="ViewBag.FacilityID"&gt;
                &lt;option value=""&gt;-- Select Facility --&lt;/option&gt;
            &lt;/select&gt;
            &lt;span asp-validation-for="FacilityName" class="text-danger" /&gt;
        &lt;/div&gt;
</code></pre>

<p>My FacilityRevenue Model is as follows:</p>

<pre><code> public partial class FacilityRevenue
{
    public string FacilityName { get; set; }
    public DateTime Date { get; set; }
    public decimal? TotalInvoices { get; set; }
    public decimal? TotalRevenue { get; set; }
    public int RecordId { get; set; }
    public int? FacilityId { get; set; }

    public virtual FacilityMaster Facility { get; set; }
}
</code></pre>

<p>The stack trace is as follows:</p>

<pre><code>System.NullReferenceException: Object reference not set to an instance of an 
object.
at Microsoft.AspNetCore.Mvc.Rendering.MultiSelectList.Eval(Object container, 
String expression)
at Microsoft.AspNetCore.Mvc.Rendering.MultiSelectList.
GetListItemsWithValueField()
at Microsoft.AspNetCore.Mvc.Rendering.MultiSelectList.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.
GenerateGroupsAndOptions(String optionLabel, IEnumerable`1 selectList,  
ICollection`1 currentValues)
at 
Microsoft.AspNetCore.Mvc.ViewFeatures.
DefaultHtmlGenerator.GenerateSelect(ViewContext viewContext, ModelExplorer 
modelExplorer, String optionLabel, String expression, IEnumerable`1 
selectList, ICollection`1 currentValues, Boolean allowMultiple, Object 
htmlAttributes)
at 
Microsoft.AspNetCore.Mvc.TagHelpers.SelectTagHelper.Process(TagHelperContext 
context, TagHelperOutput output)
at   
Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.
ProcessAsync(TagHelperContext context, TagHelperOutput output)
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.
&lt;RunAsync&gt;d__0.MoveNext()
</code></pre>

<p>How do I remedy the above error and achieve the functionality of hydrating the select control with a list of facilities?</p>