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();
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.
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'
.