I have this code which works in EntityFrameworkCore.
public void SaveProject(Project item)
{
var existing = _context.Projects.FirstOrDefault(a =&
In EntityFramework Core, it can now be done using the Update method:
DbContext.Update- (item);
this.SaveChanges();
In version 2.1, the Update method can now be used for both new and existing entities if the Id property is auto-generated.
The Docs
The downside to this is that all properties are marked as modified, even if they are the same. The issue with this is that if you are logging changes in a database trigger, then every property will be flagged as changed, even when they are not. If you only want specific properties updated, then you need to get the entity from the database, update as desired, then save.