The project uses the entity-framework version 6.1.3.
In different sources I have seen different ways to delete a record from the database:
- Mark object as deleted:
_context.Entry(obj).State = EntityState.Deleted;
- Use the
Remove()
method:_context.Set<T>().Remove(obj);
In both cases, the deletion will occur the next time you call the SaveChanges()
method.
I tried to find out the differences between these methods: I could not find anything intelligible.
Tell me in what cases it is customary to use one or another method, maybe there are some nuances / recommendations?