Q:

Use MVC to create multiple ids and names with the same name but incremented number at the end of name

I want to create multiple entities from a single form with parameters that have the same name.   I'm trying to create an array starting with 1 and ending in the max number of items in the array.  Does entity framework do this by default.
Example:
PersonName(1): "Bob"
PersonName(2): "John"
PersonName(3): "Mindy"

If I loop through collections using entity framework is there a preferred method for name and id attributes.
Html:
<input name="personname(1)" id="personname(1)" value="Bob" /><br />
<input name="personname(2)" id="personname(1)" value="John" /><br />
<input name="personname(3)" id="personname(1)" value="Mindy" /><br />

Also I noticed that when I use @Html.EditorFor it has some overloaded methods to name the id and name attributes.  So would it be recommend to build these using the template name set to empty string, and the 
htmlFieldName="personname" + "(" + i + ")";

Or is there a preferred technique?

A:

If you use the Html helpers, it does this for you automatically, especially if you use the EditorTemplates.  For example:
@for(int i=0, i<collection.Count; i++)
{
    Html.TextBoxFor(m => m.collection[i].Name);
    <input type="submit"/>
}

This creates the input elements with the proper indexing.  The better way is to simply use editor templates though:
@Html.EditorFor(m => m.collection)

A:

The correct answer is you have to add the parent table as the Model.  In every reference to any child fields or child tables's fields you have to refer to this parent model first.  All child models must drill down in the EditorFor's HiddenFor's, TextBoxFor's etc... by calling on the parent model first.  Without the parent it won't know how to correctly relate to it when its time to perform the save changes or when editing it needs to check the proper references.   Both the parent ids and child ids must be listed out in order to combine all tables in a single form and then perform a save changes on the fields.  Otherwise it won't include those fields or it will not be able to save that table correctly and not auto generate... yes I said "auto generate" the ids.  If you try and auto generate the ids yourself it will make maintenance a nightmare.
There... I filled in all the information a noob will need to surpass the point farmers.
So why is this important?  Because if the @Model does not point to the top most object that all other object are related to then it doesn't know how the reference relates.  Example would be a Document table.  But the Document table might have a foreign key to a Title table.  That would be one to one.  The Document table would still need to be listed first like so Document.Title.TitleName.  In a one to many like in an Author... b/c there might be more than one Author.. you would still list Document first.  As in Document.Authors  ... author would be a collection so you would loop through each author.  But at the very top even in Partials you would still only reference @modelDocument and not the author, that would be after the @Model portion in the content area.  If you try and reference just the @model author portion. Now it doesn't understand how it relates to the document and you either have to add the document identifier inside the author table's foreign key for the documentid at some point later downstream after adding the author.  This is unfortunate as its not necessary if you just started with the Document to begin with.
Of course this can get a little more complicated b/c you can have more than one document per author so a linking table to a documentauthors table would be preferable here... but still Document table would still be listed at the top of a partial view and even the main view in order to completely place the correct identifiers and names in an html page so that when the form is submitted it properly knows how everything is realted.  Also the identifiers should be placed in the html helpers for hidden input fields if they are not to be displayed outwardly to the users.
Now to make it an incremented number of times and to start with a certain grouping... it would require a query string or a posting attributes to send the start and stop range for that group or list of authors, or list of books, or documents or whatever.  Since the one to many and many to many relationships should be output in for loops, it can select the correct relationships to retrieve and select also the ones to be displayed using linq for the entity framework which is supplied in a private member variable that allow you to perform database crud ops.
For the point farmers... nothing.

