Reputation: 194
I have a MVC 5 project which I created in an older version of Visual Studio and have opened in VS2019. It complies fine but my view pages are seeing errors from the Model which is IEnumerable(of T). For example, If Model.Count > 0 Then
tells me "Count" is not a member of IEnumerable(of T). Also, Model.FirstorDefault
gives the same error. I tried updating the packages in NuGet but to no success. What am I missing here? This is a completely valid and working project before opening in VS2019.
I have abbreviated the code to just the model in question
Repo:
Public Function GetFilesByTagID(ByVal tagID As Integer) As IEnumerable(Of File)
Dim Files As IEnumerable(Of File)
Files = From p In archiveDB.Files
Where p.Tags.Any(Function(t) t.TagID = tagID)
Select p
Return Files
End Function
Controller:
Private ar As New ArchiveRepository
Function Index(ByVal tagID As Integer) as ActionResult
Return View(ar.GetFilesByTagID(tagID))
End Function
Razor Page:
@Modeltype IEnumerable(Of Intranet.File)
<h2>
Archives
@If Model IsNot Nothing Then
If Model.Count > 0 Then
@<small>
@Model.FirstOrDefault.Tags.Where(Function(t) t.TagID = CInt(Request.QueryString("tagID"))).FirstOrDefault.Name
</small>
End If
End If
</h2>
Upvotes: 0
Views: 151
Reputation: 194
Solved it by running Visual Studio as an Administrator. Thanks Windows 10. Can anyone explain why this is an issue for an existing project and not a new one?
Upvotes: 1