The error says all what's the problem.
Your partial view expects Model of type TerminalHost.Models.buildingInfo
while you are passing List<TerminalHost.Models.buildingInfo>
which means you are returning List<TerminalHost.Models.buildingInfo>
but in your partial view it is :
@model TerminalHost.Models.buildingInfo
replace it with:
@model List<TerminalHost.Models.buildingInfo>
or return single object form the action.
UPDATED:
Replace Html.Partial("buildingForm")
with: @Html.RenderAction("buildingForm")
and you action should be like this:
public ActionResult buildingForm() {
var model = new buildingInfo();
return View(model);
}
Your PartialView its name should be buildingForm.cshtml and it should be in Views>>Home:
@model TerminalHost.Models.buildingInfo
@{
ViewBag.Title = "Create";
Layout = null;
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>buildingInfo</legend>
<div class="editor-label">
@Html.LabelFor(model => model.buildingNumber)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.buildingNumber)
@Html.ValidationMessageFor(model => model.buildingNumber)
</div>
....
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Your building action :
public ActionResult building()
{
var buildingModel = _db.buildings.ToList();
return View(buildingModel);
}