I have the following method where I bring the data from the database
//Traer categoria
public List<categoria> listar()
{
var cate = new List<categoria>();
using (var ctx = new ACME())
{
cate = ctx.categoria.ToList();
}
return cate;
}
I'm seeing it in the following way
public ActionResult Categoria()
{
return View(ct.listar());
}
In the view I add the model (I do not know if it is right or wrong at this point)
@model LicoreraDist.Models.ACME
and finally I try to show the data I have
@foreach (var m in Model.categoria)
{
<ol class="list-group list_of_items">
<li class='list-group-item'><div class='text_holder'> @m.categoria1<div
class='btn-group pull-right'><button class='delete btn btn-
warning'>Borrar</button><button class='edit btn btn-
success'>Editar</button></div></div><br /></li>
</ol>
}
According to me "it's okay", but when I try to see the result on the website it shows me the following:
El elemento de modelo pasado al diccionario es de tipo 'System.Collections.Generic.List'1[LicoreraDist.Models.categoria]', pero este diccionario requiere un elemento de modelo de tipo 'LicoreraDist.Models.ACME'.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
Detalles de la excepción: System.InvalidOperationException: El elemento de modelo pasado al diccionario es de tipo 'System.Collections.Generic.List'1[LicoreraDist.Models.categoria]', pero este diccionario requiere un elemento de modelo de tipo 'LicoreraDist.Models.ACME
The error is yes or yes in the reference to the model in the view, what would my error be in specific?
Thank you very much