当我尝试编辑我的帖子时,会引发此错误。
这是我的代码:
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return NotFound();
}
// issue
var news = await _context.News.FindAsync(id);
if (news == null)
{
return NotFound();
}
return View(news);
}
Run Code Online (Sandbox Code Playgroud)
调试器将代码停止在
var news = await _context.News.FindAsync(id);
Run Code Online (Sandbox Code Playgroud)
我的模型的代码是
public int id { get; set; }
[Required(ErrorMessage = "Enter your name.")]
public string Author { get; set; }
[Required(ErrorMessage = "Enter the title.")]
public string Title { get; set; }
[Required(ErrorMessage = "Enter the issued date.")]
[DataType(DataType.Date)]
public …Run Code Online (Sandbox Code Playgroud) c# entity-framework entity-framework-core asp.net-core-mvc asp.net-core