Search code examples
c#databaseentity-framework-coredbcontextsavechanges

Immediately receive saved item(s) on calling DbContext.SaveChanges()


I would like to implement two custom SaveChanges() methods in my DbContext, where those return the saved entity/entities when calling SaveChanges() instead of the number of affected rows.

I am using EF Core 2.0.

What would be the best way to accomplish that?

Best regards


Solution

  • EF Core returns the objects on calling context.Add()/Update()/Remove() etc. Therefore i can retrieve them this way.