Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 17885

The difference between Update and Attach (EF Core)

$
0
0

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();}

Viewing all articles
Browse latest Browse all 17885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>