troubleshooting Question

The required column was not present in the results of a 'FromSql' operation.

Avatar of Peter Groves
Peter GrovesFlag for Canada asked on
ASP.NETMicrosoft SQL Server* stored prcedure
2 Comments1 Solution12 ViewsLast Modified:
I get this error retrieving data from server. Yet if I execute the stored procedure from server explorer it shows all the data fine.  
namespace OASIS_MVC.Models
    public partial class AnalSubTask
        public int subTaskID { get; set; }
        public string Ident { get; set; }
        public DateTime? DateCreated { get; set; }

Open in new window

       public async Task<IActionResult> Index()
            var getanalsub = (IEnumerable<AnalSubTask>)_context.AnalSubTasks.FromSqlRaw("spGetanalsub null").ToList();
                return View(getanalsub);

Open in new window

namespace OASIS_MVC.Data
    public class ApplicationDbContext : DbContext
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)

        public DbSet<AnalSubTask> AnalSubTasks { get; set; }

Open in new window

SELECT Anal_sub_task.ident,
       Anal_sub_task.sub_TaskID ,
  FROM DATAHUB.dbo.Anal_sub_task
       where  Anal_sub_task.reseau = ISNULL(@res,Anal_sub_task.reseau) 

Open in new window

This is from the serer explorer stored procedure execution that shows sub_TaskID is there.
I tried add [Primary Key] to sub_TaskID  in the stored procedure , as it is the primary key for the table.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros