© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
23 replies
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()
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?

public async Task UpdateEntityAsync()
{
    try
    {
        await _dbContext.SaveChangesAsync();
    }
    catch (Exception)
    {
        //
    }
}
public async Task UpdateEntityAsync()
{
    try
    {
        await _dbContext.SaveChangesAsync();
    }
    catch (Exception)
    {
        //
    }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

EF Entity 'required' property
C#CC# / help
2y ago
Best way to model different options in EF Core
C#CC# / help
2y ago
How to create entity correctly? [EF CORE]
C#CC# / help
2y ago