System.Web.Mvc.HtmlHelper<ModelName> does not contain a definition for

Please try to close and re-open the solution for the changes to be picked up by editor. After doing that I don't get the error

System.Web.Mvc.HtmlHelper does not contain a definition for 'BeginCollectionItem' and no extension method 'BeginCollectionItem' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assmebly reference


It is a third party library by Steve Sanderson, which you have to install first from https://www.nuget.org/packages/BeginCollectionItem/:

Install-Package BeginCollectionItem

I needed to add

<add namespace="HtmlHelpers.BeginCollectionItem" />

to the namespaces in the web.config of the Views folder. Mine was in an "Areas" folder so I needed to add it in the Views folder there.

You can also add a using statement right on the view instead, but then you have to remember to add it to each view.