(Using MVC4 VB EF4 MSSQL Razor)
I created a Stored Procedure in the MS SQL 2008 database. Then I've added that SP into the Entity Framework model (you do not see it after opening the .edmx file, i see the SP when i open the model browser). Next i did an "Add function import..." . I did [Get Column Information] and "Create new complex type".
So now I'd like to use that SP. And using ExecuteStoreQuery seems the way to go.
The best attempt so far is this:
Function Index() As ViewResult
Dim context As New MyEntities
Dim Result
' Call the SP with parameter "A"
Result = context.ExecuteStoreQuery(Of MySP_Result)("MySP @p0", "A").ToList
Return View(Result)
End Function
Where "MySP_result" is the name of the Complex Type that is returned by the SP (i see it in the EF model browser). After pressing F5 i get:
The model item passed into the dictionary is of type System.Collections.Generic.List, but this dictionary requires a model item of type System.Collections.Generic.IEnumerable
So what do i have to change?
A standard genereated list view starts with:
It took me a while to understand the error message correctly. you need to change that line into:
I also changed the controller code a little: