i am new to MVC 5 and ASP.NET, EF6 and now i have a Problem with a named EditorTemplate.
My Model looks like this:
public CADASTRO()
{
this.verificacao = new HashSet<verificacao>();
}
public int IdCADASTRO { get; set; }
public string NOME { get; set; }
public string NOME_FANTASIA { get; set; }
public string RUA { get; set; }
public string CODIGO_POSTAL { get; set; }
public Nullable<System.DateTimeOffset> DATA_CREDENCIAMENTO { get; set; }
public int IdSERVICO { get; set; }
public int IdSITUACAO { get; set; }
public int IdVerificacao { get; set; }
public int idMunicipio { get; set; }
public string TELEFONE { get; set; }
public string e_DOCS { get; set; }
public string CNPJ { get; set; }
public string bairro { get; set; }
public string email { get; set; }
public Nullable<int> anosVenc { get; set; }
public virtual MUNICIPIO MUNICIPIO { get; set; }
public virtual SITUACAO_CADASTRAL SITUACAO_CADASTRAL { get; set; }
public virtual Tipo_Servico Tipo_Servico { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<verificacao> verificacao { get; set; }
public partial class verificacao
{
public int IdVerificacao { get; set; }
public Nullable<System.DateTimeOffset> data_Vistoria { get; set; }
public string avaliador1 { get; set; }
public string avaliador2 { get; set; }
public Nullable<int> fk_cadstro { get; set; }
public virtual CADASTRO CADASTRO { get; set; }
}
And i have a EditorTemplate called verificacao, thats look like this:
@model webCrud.Models.verificacao
@Html.EditorFor(model => model.avaliador1)
My Problem is now that in my addView i can´t call:
@Html.EditorFor(model => model.verificacao,"verificacao")
I get this error:
The model item passed into the dictionary is of type 'System.Collections.Generic.HashSet`1[webCrud.Models.verificacao]', but this dictionary requires a model item of type 'webCrud.Models.verificacao
The editor needs an item, and you passed it a set of items; as indicated by the error. Iterate your set, and then call the editor on each individual item, or change your code so that you know which item is supposed to have an editor in that situation.