MVC + EF + daughter entity in the same edit form

0

I have 2 entities, one being "daughter" of the other and I need both of them to be updated in the same form.

For example:

public class EntidadeMae {
    public int Id { get; set; }
    public string Nome { get; set; }
    public IEnumerable<EntidadeFilha> Filhas { get; set; }
}

public class EntidadeFilha {
    public int Id { get; set; }
    public string Nome { get; set; }
}

When using MVC, with HTML helpers, how to create a Daughter Entity list within the Mae Entity form, without using much JS? Normally, I only treat one entity (BeginForm and helpers help, and the action needs only 1 parameter, of the same type as the View model) and I can solve only with MVC and actions, but I came across this case and did not I know how to solve. I need a form / modal for child entities that will be linked to the parent entity and created in the database only when the main form is saved.

    
asked by anonymous 07.02.2018 / 20:33

0 answers