I want to upsert reference members of an existing entity.
Do I have to write specific code for the upsert?
meaning: I have to check if I\'m handling an existing
"optimistic" approach for simple scenarios (demos)... dbContext.Find()'s intellisense help tells us that it either retrieves entity by key if already present in current context, or queries the database to get it... then we know if it exists to either add or update. i'm using EFCore v2.2.0.
var existing = _context.Find(new object[] {item.ProductId});
if (existing == null) _context.Add(item);
else existing.Quantity = item.Quantity;
_context.SaveChanges();