问题
Tried calling the new column I made in my database via Razor, throwing an error in a different file. I am completely unsure what any of this means.
Server Error in '/' Application.
Invalid column name 'ProductImage'.
Description: An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'ProductImage'.
Source Error:
Line 19: {
Line 20: var products = db.Products.Include(p => p.Supplier);
Line 21: return View(products.ToList());
Line 22: }
Line 23:
Here is where I am calling on the item in Razor (my Index view of my controller that I added the new column in)
@foreach (var item in Model)
{
<tr>
<td>
<div class="col-lg-4 col-sm-6">
<div class="single_category_product">
<div class="single_category_img">
<img src="~/Content/img/storefront/@item.ProductImage" alt="">
<div class="category_social_icon">
<ul>
<li><a href="#"><i class="ti-heart"></i></a></li>
<li><a href="#"><i class="ti-bag"></i></a></li>
</ul>
</div>
<div class="category_product_text">
<a href="single-product.html"><h5>@Html.DisplayFor(x => item.Name)</h5></a>
<p>@Html.DisplayFor(x => item.Price)</p>
</div>
</div>
</div>
</div>
</td>
<td>
@Html.ActionLink("Details", "Details", new { id = item.ProductID })
@if (User.IsInRole("Admin"))
{
@Html.ActionLink("Edit", "Edit", new { id = item.ProductID })
@Html.ActionLink("Delete", "Delete", new { id = item.ProductID })
}
</td>
</tr>
}
来源:https://stackoverflow.com/questions/60713630/added-a-new-table-to-my-database-throwing-an-invalid-column-error