How to update records using Entity Framework Core?
How to update records using Entity Framework Core?
357
06-Jul-2023
Updated on 07-Jul-2023
Aryan Kumar
07-Jul-2023There are two ways to update records using Entity Framework Core:
SaveChanges()method.Modified, and then calling theSaveChanges()method.Here is an example of how to update an entity in a connected scenario:
C#
Here is an example of how to update an entity in a disconnected scenario:
C#
In both cases, the
SaveChanges()method will update the entity in the database.Here are some additional considerations when updating records using Entity Framework Core:
BulkInsert()orBulkUpdate()methods instead of callingSaveChanges()multiple times.Include()method to specify which properties of an entity you want to update. This can improve performance by reducing the amount of data that needs to be transferred between the database and the application.