The required column was not present in the results of a 'FromSql' operation. ( Stored procedure with Oracle)

asp.net-core entity-framework-core

Question

wanted to call a stored procedure with oracle so after searching I found that to do this I have to create a model and make context and of these things. but after doing that I got this out of nowhere

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

I'm working with asp core 2.2 and EF Core 2.2.1, now I'm getting these and I can't figure it out how to fix it or what is wrong .

I tried many things but nothing changes

Here are my files

Model

namespace test2._2.Models
{
    public class CodeProc
    {
        public int ID { get; set; }
        public int Erorrcode { get; set; }
        public string ErrorMsg { get; set; }
    }
}

Context

namespace test2._2.Models
{
    public partial class ModelCodingContext : DbContext
    {
        public ModelCodingContext(DbContextOptions<ModelCodingContext> optionss)
            : base(optionss)
        {
        }

        public virtual DbSet<CodeProc> CodeProcs { get; set; }
    }
}

the actual procedure to call and run and print the results

var result = await _dbCodingContext.CodeProcs.FromSql("begin FIX_CODING.GET_CLIENT_CODE12(245,255,:num1,:num2,:msg);end;", oracleParameter, oracleParameter2, oracleParameter3).ToArrayAsync();

ViewData["test"] += result.ToString();
1
0
1/16/2019 12:43:59 PM

Accepted Answer

Luckily, I solved my own by making the stored procedure to return a refcursor rather than 3 values and it went for good. but I wonder what to do if it returns values not a refcursor.

0
1/17/2019 4:22:44 PM

Popular Answer

Your required columns are: ID, Erorrcode, ErrorMsg

Check that the stored procedures returns exactly these columns. Account for case sensitivity, so 'ID' doesn't equal 'Id' as well as 'Errorcode' doesn't equal 'ErrorCode'.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow