Marking changed properties instead of using the traditional Update is a good practice? (Ef core)

Asked

Viewed 31 times

0

I have chosen to use the update in this way:

_context.Entry(site).State = EntityState.Unchanged;
_context.Entry(site).Property(x => x.Name).IsModified = true;
_context.Entry(site).Property(x => x.Description).IsModified = true;
_context.Entry(site).Property(x => x.Link).IsModified = true;

Landmark as Unchanged every entity and then mark the properties that have possibly been modified that in my view it generates more performance and avoids errors, but this is a good practice or is waste of time?

  • 1

    will depend on the context, if it is an entity, there is no need, but as we do not have a real context it is difficult to give an answer. If you can edit your question and improve with a clear example.

1 answer

1

I prefer to use Ismodified in the whole entity, I don’t think it’s a bad practice and I also see no problem in the form you used.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.