Is that possible, DbContext.SaveChanges() returns 0 but doesn't have an exception?
According to the documentation, the return value of DbContext.SaveChanges
is
The number of objects written to the underlying database.
So what you see is only possible, when no entities needed to be saved to the database.
Entity Framework's db.SaveChanges()
for deletes and saves returns the number rows being affected. In test using the Fakes Framework (stubs and shims), however, the value returned will always be 0.
If there is an error in the call, then an exception will be thrown. The implication is that any calling method relying on a value greater than zero returned from db.SaveChanges()
for confirmation cannot be tested for that same value.
This may prove critical when a method is using the db.SaveChanges()
return value to evaluate the number of rows affected in a given operation.