I am working on an asp.net mvc application using C#. For database, I am using Entity Framework and code-first approach. I have an sql view that I need to execute and store its result in a list. I know how to query data from DB using ApplicationDbContext, stored procedure and inline queries. But now I want to do the same using a view.
The view looks like this
CREATE VIEW [dbo].[GenresView]
AS SELECT * FROM Genres
I have a Genre class that has the same properties that the view will return.
Steps to handle a view:
IMPORTANT!!! It is better to define all fields which you want to get instead of * .