Skip to content
Advertisement

How to get a list of all Table names through asp.net API controller

So I want to get a list of all the table names from the database through a controller as an ASP.net API project. I tried to do it through raw sql query without entity and it looked something like this.

But when I try to use the SqlQuery method I get the error ” ‘DatabaseFacade’ does not contain a definition for ‘SqlQuery’ and no accessible extension method ‘SqlQuery’ “. Anybody that has any idea how to solve this?

Advertisement

Answer

First create an Helper method in your controller as shown below

using System.Data.SqlClient;

Then call in your action Like this

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement