I am building a Web API service that will generate oData. I'm using a "Database First" approach in that I've created an EDM in my "Models" folder containing a view.
I had Visual Studio scaffold a Controller for me based on the EDM.
Now I'm trying to figure out the routing code to put in my WebApiConfig.cs file. Every example I've found so far on the internet has involved Code First approaches. Does anyone know how to do this from a Database First approach?
I found where I went wrong.
First of all, I added the wrong scaffolded controller. Originally when I added my controller, I went to (right-click "Controllers") --> Add --> New Scaffolded Item, as seen below. It gave me 2 possible Web API Controller options. I picked the one that would come pre-filled with CRUD functionality based on Entity Framework.
Turns out, what I should have done was go to (right-click "Controllers") --> Add --> Controller, as seen below. From there I could add an ODATA controller!
Icing on the cake? At the top of the controller, commented out, was the very code I needed for the WebApiConfig.cs!
Now, fair warning, when you run your code, it will show an error at first.
For example: I changed my url to "http://localhost:51044/odata/vw_FilesToBeProcessed_Dashboard" and I got my odata output!