title: rename mvc model object in Razor View
body: <p>I'm using MVC 4 and usually Visual Studio will create all the views for you. I have one form that just has one field and I want to just embed the create form into the Index View.</p>
  
  <p>So the Index View has something like <code>@model IEnumerable&lt;Models.LinkModel&gt;</code></p>
  
  <p>So I access it by iterating through the Model collection.</p>
  
  <p>But if I try to embed the form for the create action I need <code>@model Models.LinkModel</code> 
  and it is accessed by Model.Name as well. Is there a way to do this or use a different variable name?</p>
  
  <p><strong>Ok here is some extra info.</strong></p>
  
  <p>SO I have a model.</p>
  
  <pre><code>public class LinkModel
  {
     public string LinkUrl {get;set;}
  }
  </code></pre>
  
  <p>I have a controller that has the Create and Index ActionResults.</p>
  
  <p>Now in the Index view I have </p>
  
  <pre><code>@model IEnumerable&lt;Models.LinkModel&gt;
  
  @{
      ViewBag.Title = "Links";
  }
  </code></pre>
  
  <p>I can do all my fancy logic to list all the links. </p>
  
  <pre><code>@foreach(link in Model)
  {
      &lt;p&gt;link.LinkUrl&lt;p&gt;
  }
  </code></pre>
  
  <p>The Create View has this </p>
  
  <pre><code>@model Models.LinkModel // Note that it is just one item not IEnumerable
  
  @{
      ViewBag.Title = "Add Link";
  }
  
  @using (Html.BeginForm())
  {
      @Html.ValidationSummary(true)
  
      &lt;fieldset class="editor-fieldset"&gt;
          &lt;legend&gt;LinkModel&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.LinkUrl)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.TextBoxFor(model =&gt; model.LinkUrl)
          &lt;/div&gt;
         &lt;p&gt;
          &lt;input type="submit" value="Add Link" /&gt;
         &lt;/p&gt;
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>Now it seems pretty stupid to have a create form for just one field. I want to put this form on the Index page. Problem is that I access the object using the variable Model. I wanted to know if there is a way to have two seperate instances or be able to access the Model objects with different names.</p>