This is the error:
System.Data.Entity.Core.EntityCommandExecutionException: 'The data reader is incompatible with the specified 'TreinamentoCrudApi.Context.Cidade'. A member of the type, 'id', does not have a corresponding column in the data reader with the same name.'
If in SP I put one:
select * from tabela
- > works
But if I do this:
select nome from tabela
- > returns the error quoted
My model looks like this:
public class Cidade
{
[Key]
public int id { get; set; }
[Required]
public String nome { get; set; }
}
Calling the SP in the API
public class GetCidade
{
BancoContext banco = new BancoContext();
public List<Cidade> GetCidades()
{
return banco.Database.SqlQuery<Cidade>("exec sp_cons_cidade").ToList();
}
}
My proc in the database runs normally. How do I resolve this?