Amigos boa tarde!
Estou tentando gerar uma view para listar uns estilos de musica, gerei o edmx,model e controller sem problemas, porem na visualização estou tendo problema.
Se eu tento exibir a view dessa maneira:
@model IEnumerable<Cidadao.Models.Estilo>
@{
ViewBag.Title = "Index";
}
<h2>
Estilos</h2>
<ul>
@foreach (var estilo in Model)
{
@estilo.Estilos
}
</ul>
ele me gera o seguinte erro
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Cidadao.Estilo]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Cidadao.Models.Estilo]'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Cidadao.Estilo]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Cidadao.Models.Estilo]'.
Porem se eu executo dessa maneira:
Ele roda normalmente
@model IEnumerable<Cidadao.Estilo>
@{
ViewBag.Title = "Index";
}
<h2>
Estilos</h2>
<ul>
@foreach (var estilo in Model)
{
@estilo.Estilo1
}
</ul>
e tem um exemplo que eu havia feito acompanhando uma documentação da microsoft que o primeiro modo funcionou, agora que estou tentando criar sozinho não consegui.
Isso pode ser algum erro, ou está correto mesmo?
Obrigado!
"Nunca deixe que os outros te subestimen, mas tambem não seja arrogante seja humilde e prove quem é