Prior to MVC 5 the DropDownList was scaffolded in my Razor Edit View as:
@Html.DropDownList("EntityId", String.Empty)
But now the equivalent (post MVC 5) is scaffolded as:
@Html.DropDownList("EntityId", null, htmlAttributes: new { @class = "form-control" })
I want to add the htmlAttributes to keep the UI consistent, but the DropDownList no longer works as expected for a nullable EntityId (int ? EntityId). The problem is that the default item is set to the first item in the list if EntityId is null. I want a blank item if the id is null, and the appropriate selection if not.
PS. My controller builds the list as follows:
ViewBag.EntityId = new SelectList(db.Entities, "EntityId", "Name", EntityId);
ViewBagSelectList property)