Search code examples
asp.net-coreentity-framework-core

How to get storedProcedure result containing joins From EF core8 Without creating Table?


I want to call a stored procedure in an asp dot net core8 API and get it's result from sql. but as the example shows, the procedure is getting called from a DbSet like Poll and query result is converted to PollEntity:

 List<PollEntity> polls =await _dbContext.Polls.FromSql($"SpGetPoll").ToListAsync();

But I don't want to create a Poll DbSet, which then should add a migration and create a table in database.

I want to call procedure, and then getting it's result without creating table for it. because the procedure result is not from only one table like StudentTable as online examples show in other sites.


Solution

    1. You can use EF Core 8 SqlQuery Raw SQL queries for unmapped types
    2. You can exclude entity from migrations EF Core 5.0: Excluding Tables from Migrations