I'm developing an MVC application with Entity Framework in Code First.
As my database has procedures, I chose to use SQLQuery to execute the procedures, but I'm getting away with this error:
Não existe mapeamento do tipo de objeto System.Data.Entity.Core.Objects.ObjectParameter para um provedor gerenciado de tipo nativo.
Here is the code for the DbContext class:
public DTODados GetDadosProcedure(string codUsuario, string senhaCript)
{
return Database.SqlQuery<DTODados>("ProcedureGenerica",
codUsuario != null ?
new ObjectParameter("codUsuario", codUsuario) :
new ObjectParameter("codUsuario", typeof(string)),
senhaCript != null ?
new ObjectParameter("senhaCript", senhaCript) :
new ObjectParameter("senhaCript", typeof(string))
).SingleOrDefault();
}
Following this link