C# 为什么不能在EF core中输入某些单词

C# 为什么不能在EF core中输入某些单词,c#,html,css,asp.net-mvc,entity-framework,C#,Html,Css,Asp.net Mvc,Entity Framework,我试图使ef核心编辑页面。但是,当我尝试输入一些单词时,输入类型没有单击,我无法写入任何单词。(现有的除外) 下面是有问题的cshtml代码 @model PineBerry01.Models.BerrySuggest @{ ViewData["Title"] = "Edit"; } <!--TODO: 여기서부터 다시 개발하기--> <head> <link rel="stylesheet" href="~/css/ManagerNotice

我试图使ef核心编辑页面。但是,当我尝试输入一些单词时,输入类型没有单击,我无法写入任何单词。(现有的除外) 下面是有问题的
cshtml
代码

@model PineBerry01.Models.BerrySuggest
@{
    ViewData["Title"] = "Edit";
}


<!--TODO: 여기서부터 다시 개발하기-->
<head>
    <link rel="stylesheet" href="~/css/ManagerNotice/AddNotice.css" />
</head>
<div class="sa">Suggestion Addition</div>
<div class="line"></div>

<div class="sum" style="position: relative; z-index: 2;">
</div>
<div>
    <form asp-action="Edit" method="post">
        <!--- Add QnA--->
        <div class="sa">Announcement Addition</div>
        <div class="line"></div>
        <div asp-validation-summary="ModelOnly" class="text-da"></div>
        <div class="sum" style="position: relative; z-index: 2;"></div>
        <!--Title-->
        <div class="sum2">
            <div class="bold" style="float:left;margin:116px 0px 0px 66px;">Title</div>
            <input asp-for="SuggestTitle" class="write" style="float:left; margin:116px 0px 0px 20px;" />
        </div>
        <!--Content-->
        <div class="sum3">
            <div class="bold" style="float:left;margin:26px 0px 0px 66px;">Content</div>
            <textarea asp-for="SuggestContent" class="write2" style="float:left;margin:26px 0px 0px 20px;"></textarea>
        </div>
        <div>
            <a asp-action="Index">
                <img src="https://i.ibb.co/n77wnyj/returm.png" class="backimage" alt="returm"
                     style="position: relative; z-index: 2; margin: 70px 0px 0px 615px;" border="0">
            </a>
            <div class="back" style="margin: -28px 0px 0px 601px; position: relative;"></div>
            <input class="submit" style="margin: -28px 0px 0px 658px;" value="FinishEdit" />
        </div>
    </form>
</div>
<!--end Back and Submit-->


<div class="pinkbox" style="position: relative; z-index: 1; margin:-450px 0px 0px 35px;"></div>
<div class="copyright" style="margin:265px 0px 27px 246px;">2019 Copyright ⓒ Team VaryBerry All Right Reserved.</div>
以下是控制器

public async Task<IActionResult> Edit(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var suggest = await _context.BerrySuggests.FindAsync(id);
            if (suggest == null)
            {
                return NotFound();
            }
            return View(suggest);
        }

        [HttpPost, ActionName("Edit")]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> EditPost(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var suggestToUpdate = await _context.BerrySuggests.FirstOrDefaultAsync(s => s.BerrySuggestKey == id);
            if (await TryUpdateModelAsync<BerrySuggest>(
                suggestToUpdate,
                "",
                s => s.SuggestTitle,
                s => s.SuggestContent))
            {
                try
                {
                    await _context.SaveChangesAsync();
                    return RedirectToAction(nameof(Index));
                }
                catch (Exception)
                {
                    ModelState.AddModelError(string.Empty, "ErrorMessage");
                }
            }
            return View(suggestToUpdate);
        }
但它犯了一个错误。所以我甚至不能检查它。 以下是错误代码

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'PineBerry01.Models.BerrySuggest', but this ViewDataDictionary instance requires a model item of type 'PineBerry01.ViewModel.BerrySuggestViewModel'.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary..ctor(ViewDataDictionary source, object model, Type declaredModelType)
lambda_method(Closure , ViewDataDictionary )
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.CreateViewDataDictionary(ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.Activate(object page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator.Activate(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
InvalidOperationException:传递到ViewDataDictionary的模型项的类型为“PineBerry01.Models.BerrySuggest”,但此ViewDataDictionary实例需要类型为“PineBerry01.ViewModel.BerrySuggestViewModel”的模型项。
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureRecompatible(对象值)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary..ctor(ViewDataDictionary源、对象模型、类型declaredModelType)
lambda_方法(闭包,ViewDataDictionary)
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.CreateViewDataDictionary(ViewContext上下文)
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.Activate(对象页,ViewContext上下文)
Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator.Activate(IRazorPage页面,ViewContext上下文)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAscync(IRazorPage页面,ViewContext上下文)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage页面,ViewContext上下文,bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext上下文)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext-ViewContext,string-contentType,可空状态码)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext-ViewContext,string-contentType,可空状态码)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext ActionContext、IView视图、ViewDataDictionary viewData、ITempDataDictionary tempData、string contentType、可空状态代码)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext上下文,ViewResult结果)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteSultAsync(ActionContext上下文)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g_|29_0(ResourceInvoker invoker,Task lastTask,State next,Scope Scope,object State,bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed上下文)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext(ref状态next、ref范围、ref对象状态、ref bool已完成)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g_|24_0(ResourceInvoker invoker,Task lastTask,State next,Scope Scope,object State,bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed上下文)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref状态Next、ref作用域、ref对象状态、ref bool已完成)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g_|19_0(ResourceInvoker invoker,Task lastTask,State next,Scope Scope,object State,bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g|u waiting | 17|0(ResourceInvoker invoker,Task Task,IDisposable作用域)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g_uwaitRequestTask | 6_0(端点端点、任务请求任务、ILogger记录器)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext上下文)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext上下文)

“但它出错了。”-到底发生了什么?请具体说明,这很有帮助。已在浏览器中看到错误。将
@model PineBerry01.Models.BerrySuggest
更改为
@model PineBerry01.ViewModel.SuggestViewModel
时发生错误。请查看堆栈跟踪中的这一行,
InvalidOperationException:传递到ViewDataDictionary的模型项的类型为“PineBerry01.Models.BerrySuggest”,但是,此ViewDataDictionary实例需要类型为“PineBerry01.ViewModel.BerrySuggestViewModel”的模型项。
,错误自行解释
     [DataType(DataType.Date)]
     public DateTime SuggestDate { get; set; }
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'PineBerry01.Models.BerrySuggest', but this ViewDataDictionary instance requires a model item of type 'PineBerry01.ViewModel.BerrySuggestViewModel'.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible(object value)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary..ctor(ViewDataDictionary source, object model, Type declaredModelType)
lambda_method(Closure , ViewDataDictionary )
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.CreateViewDataDictionary(ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorPagePropertyActivator.Activate(object page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator.Activate(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)