good time everyone.
I have a question regarding these two commands.
When the Attach method exists, where are we forced to use the Update method?
Thank you for explaining the difference between the two
For example
public void UpdateStudent(Student student)
{
var student = _context.Students.FirstOrDefault(s => s.Id == student.Id);
student.FullName = student.FullName;
student.Age = student.Age;
context.Students.Update(student); //or context.Students.Attach(student) ?
context.SaveChanges();
}
New contributor
Sina Miri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.