ASP 传入的.NET Core Repository Id Article 改成了0?

ASP .NET Core Respository Id Article passed in was changed to 0?

我想用 ASP .Net Core 和 Repositoy 在数据库中编辑文章,一切都很好,但是当我输入并按下编辑时,文章 ID 将变为 0 , 下面是代码

查看

    @model Megatron.ViewModels.ArticleFacultyViewModel

@{
    ViewData["Title"] = "Edit Article";
}

    <div>
        <form asp-action="EditArticle">
            <partial name="_StatusMessage" model="@ViewData["Message"]" />
            <div>
                <div class="form-group row">
                    <div class="col-2">
                        <label asp-for="Article.Title" class="col-form-label"></label>
                    </div>
                    <div class="col-5">
                        <input asp-for="Article.Title" class="form-control" />
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-2">
                        <label class="col-form-label">Type of contribution</label>
                    </div>
                    <div class="col-3">
                        <button hidden class="btn btn-primary" type="button" data-toggle="collapse" data-target="#ImportFileCollapse" aria-expanded="false" aria-controls="ImportFileCollapse">
                        </button>
                        <button hidden class="btn btn-primary" type="button" data-toggle="collapse" data-target="#TextAreaCollapse" aria-expanded="false" aria-controls="TextAreaCollapse">
                        </button>
                        <button id="button-collapse" class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="ImportFileCollapse TextAreaCollapse">
                            Switch to Editor
                        </button>
                    </div>
                </div>

问题是当您在 html 中提交表单时,您没有绑定文章的 Id。因此,EditArticle post 操作没有收到 Id,随后显示为零。