Why does my Endereco template return null after the postback?:
Template:
publicclassPaciente{publicPaciente(){Endereco=newList<Endereco>();}[Key]publicintPacienteID{get;set;}publicstringNome{get;set;}publicstringProfissao{get;set;}publicvirtualICollection<Endereco>Endereco{get;set;}}publicclassEndereco{[Key]publicintEnderecoID{get;set;}publicintPacienteID{get;set;}publicstringLogradouro{get;set;}publicstringNOLogradouro{get;set;}publicvirtualPacientePaciente{get;set;}}
HTML
@modelSGMed.Dominio.Entidade.Paciente@{ViewBag.Title=null;}@using(Html.BeginForm("Alterar", "Paciente", FormMethod.Post))
{
<p>
<input type="submit" value="Salvar Paciente" class="btn btn-primary" />
</p>
<div class="row">
<div class="col-md-12">
<fieldset>
<legend>Dados do Paciente</legend>
<div class="col-md-7">
@Html.LabelFor(model => model.Nome)
@Html.TextBoxFor(model => model.Nome, new { @class = "form-control", style = "min-width:100%;" })
</div>
<div class="col-md-2">
<label>Profissão</label>
<input type="text" id="Profissao" name="Profissao" value="@Model.Profissao" class="form-control" style="min-width:100%;" />
</div>
</fieldset>
</div>
<br />
<div class="col-md-12">
<fieldset>
<legend>Dados do Endereço</legend>
@foreach(var item in Model.Endereco)
{
<div class="row">
<div class="col-md-6">
<label>Logradouro</label>
<input type="text" id="Logradouro" name="Endereco.Logradouro" value="@item.Logradouro" class="form-control" style="min-width:100%;" />
</div>
<div class="col-md-1">
<label>Número</label>
<input type="text" id="NOLogradouro" name="Endereco.NOLogradouro" value="@item.NOLogradouro" class="form-control" style="min-width:100%;" />
</div>
</div>
}
</fieldset>
</div>
</div>