I have a 'Person' object that has a 'FirstName' and 'LastName' property. The 'Person' also has a 1-n relation with a 'Phone' object. The 'Phone' object has a 'Number' property. So a person can have multiple phone numbers.
On the 'PersonController' I have a 'Create' action that loads a strongly-typed view to show a form where I can create a new 'Person'. But besides the person's properties I also want to be able to enter a first phone child object.
This codes gives me a NullReferenceException:
Html.TextBox("Number", Model.Person.Phones.SingleOrDefault().Number)
In my action method I call the view like this:
Dim p As New Person
Return View(p)
So how can I create an object and a first child object on a single view?