ASP.NET core - can I use an sql view instead of a table in my app?

Michael Penney 41 Reputation points


I was just wondering if anyone could offer a bit of help. I'm currently a work term student and I've been asked to create a view in SQL server and use that for the application we are developing. Creating a view is easy enough but I'm not sure on how to use the view inside of the application. I'm building the app with core. Any help would be appreciated!

Mike P.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
4,899 questions
{count} votes

Accepted answer
  1. Mark Allan 416 Reputation points MVP

    Assuming you're using Entity Framework Core, make sure you're using EF Core 3 and then it will scaffold views for you as keyless entity types (previously known as query types)- see If you're tied to a previous version, you can still do it with query types in 2.1 as long as you scaffold it yourself in OnModelCreating, or whatever version you're on you can always fall back to a raw SQL SELECT statement.

    At a lower level, if you're not using EF then for most purposes you can treat views as read-only tables.

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Manoj Sharma 1 Reputation point

    Hi Mike,

    If you are use Views in the same manner as you would use a SQL Server database table object.

    So, you can either use a stored procedure to query the view and than invoke Stored procedure using ADO.NET from your ASP.NET Core application or you can also use a select query with ADO.NET against you view.

    You can refer to sample code of using ADO.NET here (


    0 comments No comments

  2. Виктор C 1 Reputation point
    0 comments No comments

  3. Dave Patrick 350.9K Reputation points MVP
    2020-06-06T21:05:10.863+00:00 core is not currently supported here on QnA. I'd try asking for help in dedicated forums here.

    --please don't forget to Accept as answer if the reply is helpful--

    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    0 comments No comments