C#C
C#17mo ago
Core

✅ EF Best way to do UPDATE on entity

Hello,
EF by default tracks entities. That means, if a property of an entity is modified, SaveChanges() will do the update.

Now, I set new values for the properties in the business logic layer, and the repository layer is responsible for any DB operation.


My current method looks like this.... Is there a clearer approach or leave this as it is?

c#
public async Task UpdateEntityAsync()
{
    try
    {
        await _dbContext.SaveChangesAsync();
    }
    catch (Exception)
    {
        //
    }
}
Was this page helpful?