I am using EF Core. I want to extract data from the database using a stored procedure and EF Core. I am getting error for those property whose are not returned from DB. How can I fix this?
Entity:
public class CustomOverview
{
public int A{ get; set; }
public int? B{ get; set; }
public int? C{ get; set; }
public int? D{ get; set; }
}
Repository code
public async Task<CustomOverview> GetMyData()
{
return _dbContext.CustomOverviews.FromSqlInterpolated($"exec spr_myStoredProcedure).AsEnumerable().FirstOrDefault();
}
My stored procedure returns data for Column A, Column B.
When I run the code, I get this exception:
InvalidOperationException: The required column 'C' was not present in the results of a 'FromSql' operation.
How can I resolve it? There is many solution where they suggest to remove property or use [NotMapped] attribute before the property. But my requirement is I need those property for different stored procedure. So I couldn't remove them.