EF Core Don't Forgets

November 18, 2024
ef tips

EF Core is great. And on an everyday basis, it you can zipp by and get shit done. But, then you need some help and what ought to be easy (and maybe is), you have no idea (or forgot) how to do it.

This is the list of things you'll forget but will need.

 

Update a property that EF Core doesn't know changed. 

Typically, you updated when it was unattached. Then attached it, but EFC be like “these are not the droids you are looking for.” Easy, with this, it'll update when you SaveChanges.

  db.Entry(item).Property(x => x.PropertyName).IsModified = true;