Object comes null in the query, even if it exists

1

I have this method in my controller

[HttpDelete]
        public HttpResponseMessage DeletaCidade(int id)
        {
            Cidade cidade = banco.Cidades.Find(id);

            if (cidade == null)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }

            banco.Cidades.Remove(cidade);

            try
            {
                banco.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK, cidade);
        }

What happens is when I pass a valid id, I get in the controller, but the city object continues NUll. How do I resolve this?

EDIT1

My Model

public class Cidade
    {
        [Key]
        public int id { get; set; }
        [Required]         
        public String nome { get; set; }
    }
    
asked by anonymous 09.08.2018 / 15:11

0 answers