_context.Entry(entity).State = EntityState.ModifiedASP.NET EF Core和之间有什么区别_context.Entity.Update(entity)?例如:
[HttpPut]
public async Task<ActionResult<Student>> PutStudent(Student student)
{
**_context.Entry(student).State = EntityState.Modified;**
await _context.SaveChangesAsync();
return student;
}
Run Code Online (Sandbox Code Playgroud)
[HttpPut]
public async Task<ActionResult<Student>> PutStudent(Student student)
{
**_context.Student.Update(student);**
await _context.SaveChangesAsync();
return student;
}
Run Code Online (Sandbox Code Playgroud)