witam,dodałem nowy model Mems
public class Mems
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Autor { get; set; }
[Required]
public string Title { get; set; }
public string coverImg { get; set; }
[Required]
public string Description { get; set; }
public string Category { get; set; }
[Required]
public DateTime? releaseDate { get; set; }
public DateTime? modifyDate { get; set; }
public int? Like { get; set; }
public int? Dislike { get; set; }
}
kiedy wywołuje się Views ->Home->index
@using Microsoft.AspNetCore.Identity
@using MemeGenerator.Models
@model IEnumerable<MemeGenerator.Models.Mems>
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
@{
ViewData["Title"] = "Home Page";
}
@if (SignInManager.IsSignedIn(User))
{
<p>Jesteś zalogowany</p>
}
else
{
<p>Nie jesteś zalogowany</p>
}
h1>@ViewData["Title"]</h1>
@Html.ActionLink("+ Dodaj mema", "Create", "Movie", null, new { @class = "btn btn-primary", @style = "margin-bottom: 20px;" })
<br>
<table class="table">
<tr>
<th>Id</th>
<th>Tytul</th>
<th>coverImage</th>
<th>Descriptionอ</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td class="item-id">@item.Id</td>
<td>@item.Title</td>
<td>
<img src="@item.coverImg" height="80px" />
</td>
<td>@item.releaseDate.Value.ToString("dd MMM yyyy")</td>
<td>@item.Category</td>
<td>@item.modifyDate</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { id = item.Id, @class = "btn btn-primary", @style = "margin-bottom: 20px;" })
</td>
<td>
<input type="button" value="Delete" class="btn btn-danger" />
</td>
</tr>
}
</table>
@using (Html.BeginForm("delete", "movie", FormMethod.Post, new { name = "frmMovie", id = "frmMovie" }))
{
<input type="hidden" name="id" />
}
@section Scripts
{
<script>
$(".btn-danger").click(function () {
if(!confirm('Do you really want to delete this movie?')) {
return false;
}
var id = $(this).closest("tr").find(".item-id").text();
document.frmMovie.id.value = id;
document.getElementById("frmMovie").submit();
});
</script>
}
wywala mi taki błąd
An unhandled exception occurred while processing the request.
SqlException: Invalid object name 'Mems'.
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)
AspNetCore.Views_Home_Index.ExecuteAsync() in Index.cshtml
+
@foreach (var item in Model)
robiłem drop-database,add-migration i update-database ale nie pomaga ,ktos wie co źle robię?