title: How to pass data from a model as data to a
body: <p>I have two models Doctor and Patients.</p>
  <p>I want to display Names of doctors in a dropdown/select in form for patients.</p>
  <p>This is how my Patients Create View Looks like:</p>
  <pre><code>@model Application.Models.Patient
  @model List&lt;Application.Models.Doctor&gt;
  @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
  
  &lt;link href=&quot;~/lib/twitter-bootstrap/css/bootstrap.css&quot; rel=&quot;stylesheet&quot; /&gt;
  &lt;script src=&quot;~/lib/jquery/jquery.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;~/lib/jquery-validate/jquery.validate.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js&quot;&gt;&lt;/script&gt;
  &lt;link href=&quot;~/css/StyleSheet.css&quot; rel=&quot;stylesheet&quot; /&gt;
  @{
      ViewData[&quot;Title&quot;] = &quot;Create&quot;;
  }
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot; /&gt;
      &lt;link href=&quot;~/lib/twitter-bootstrap/css/bootstrap.css&quot; rel=&quot;stylesheet&quot; /&gt;
      &lt;title&gt;@ViewBag.Title&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
          &lt;div class=&quot;sidebar&quot;&gt;
              &lt;nav class=&quot;nav flex-column&quot;&gt;
                  &lt;a asp-controller=&quot;Home&quot; asp-action=&quot;Index&quot; class=&quot;nav-item nav-link&quot;&gt;Home&lt;/a&gt;
                  &lt;a asp-controller=&quot;Home&quot; asp-action=&quot;Create&quot; class=&quot;nav-item nav-link&quot;&gt;Add User&lt;/a&gt;
                  &lt;a asp-controller=&quot;Home&quot; asp-action=&quot;All&quot; class=&quot;nav-item nav-link&quot;&gt;All User&lt;/a&gt;
              &lt;/nav&gt;
          &lt;/div&gt;
          &lt;div class=&quot;area card&quot;&gt;
              &lt;div class=&quot;card-body&quot; style=&quot;background-color: aqua&quot;&gt;
                  &lt;form asp-action=&quot;Create&quot; asp-controller=&quot;Patient&quot; method=&quot;post&quot;&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label asp-for=&quot;Name&quot;&gt;Patient Name&lt;/label&gt;
                          &lt;div&gt;
                              &lt;span asp-validation-for=&quot;Name&quot; style=&quot;color: red;&quot;&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;input asp-for=&quot;Name&quot; class=&quot;form-control&quot; type=&quot;text&quot; id=&quot;Name&quot; name=&quot;Name&quot; /&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label asp-for=&quot;Adress&quot;&gt;Address&lt;/label&gt;
                          &lt;div&gt;
                              &lt;span asp-validation-for=&quot;Adress&quot; style=&quot;color: red;&quot;&gt;&lt;/span&gt;
                          &lt;/div&gt;
                          &lt;input asp-for=&quot;Adress&quot; class=&quot;form-control&quot; type=&quot;text&quot; id=&quot;Adress&quot; name=&quot;Adress&quot; /&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label asp-for=&quot;BloodGroup&quot;&gt;Blood Group&lt;/label&gt;
                          &lt;select asp-for=&quot;BloodGroup&quot; class=&quot;custom-select&quot;&gt;
                              &lt;option selected&gt;Custom Select Menu&lt;/option&gt;
                              &lt;option value=&quot;A+&quot;&gt;A+&lt;/option&gt;
                              &lt;option value=&quot;A-&quot;&gt;A-&lt;/option&gt;
                              &lt;option value=&quot;B+&quot;&gt;B+&lt;/option&gt;
                              &lt;option value=&quot;B-&quot;&gt;B-&lt;/option&gt;
                              &lt;option value=&quot;AB+&quot;&gt;AB&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                          &lt;label asp-for=&quot;BloodGroup&quot;&gt;Blood Group&lt;/label&gt;
                          @{
                                                  &lt;select asp-for=&quot;BloodGroup&quot; class=&quot;custom-select&quot;&gt;
                                                      @foreach(var d in ViewBag.doc)
                                                      {
                                                      &lt;option value=&quot;&quot;&gt;@d.FirstName&lt;/option&gt;
                                                      }
                                                  &lt;/select&gt;
                          }
                      &lt;/div&gt;
                      &lt;button class=&quot;btn btn-block btn-primary&quot; type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
                  &lt;/form&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>i am not able to add two models in a single view. I get an warning &quot;the 'model' directive may only occur once per document&quot;</p>
  <p>I tried passing, List of  Doctors in View as ViewBag but it din't help.</p>
  <pre><code>[HttpGet]
  public IActionResult Create()
  {
      ApplicationContext application = new ApplicationContext();
      List&lt;Doctor&gt; doctor = application.Doctor.ToList();
      ViewBag.Doc = doctor;
      return View();
  }
  </code></pre>
  <p>What am i missing ? Please help me.</p>