dotnet / dotnet/EntityFramework.Docs
Update ISaveChangesInterceptor documentation to reflect EF Core 7 & 8 changes
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
### Type of issue
Outdated article
### Description
In EF Core 7 and 8, the semantics of SaveChanges error reporting to ISaveChangesInterceptor was changed in the following ways:
- https://github.com/dotnet/efcore/pull/26988 Added SaveChangesCanceled; SaveChangesFailed is no longer called for exceptions caught when CancellationToken is triggered (EF Core 7)
- https://github.com/dotnet/efcore/pull/30445 Removed SaveChangesFailed invocation when DbUpdateConcurrencyException is thrown (EF Core 8)
The current documentation for the [SaveChangesFailedAsync](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.diagnostics.isavechangesinterceptor.savechangesfailedasync?view=efcore-9.0) method states
> Called when an exception has been thrown in DbContext.SaveChangesAsync.
which is misleading given the above.
A consumer has no way to know about these behaviors without studying EF Core sources. The [available SaveChangesInterceptor example](https://learn.microsoft.com/en-us/ef/core/logging-events-diagnostics/interceptors#savechanges-interception) also ignores the EF Core 7 & 8 changes to the interface and error reporting protocol, further supporting the notion that SaveChangesFailed observes all exceptions.
Please update the documentation so that it clearly states which event handler is called in which scenarios.
The [SaveChangesInterceptor class documentation](https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.diagnostics.savechangesinterceptor?view=efcore-9.0) has the same issues but the code uses `` from the interface so that will probably get fixed automatically along the way.
_Both of the aforementioned changes were breaking with respect to the `ISaveChangesInterceptor` contract and were not documented as far as I could find, but given that was more than 2 years ago, it probably does not really matter at this point._
### Page URL
https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.diagnostics.isavechangesinterceptor?view=efcore-9.0
### Content source URL
https://github.com/dotnet/EntityFramework.ApiDocs/blob/live/dotnet/xml/Microsoft.EntityFrameworkCore.Diagnostics/ISaveChangesInterceptor.xml
### Document Version Independent Id
e24069a7-444a-9846-27d8-8768f20411b0
### Platform Id
70b472ba-8338-f916-d2ff-3e94790a4b37
### Article author
@dotnet-bot
Contributor guide
Assessment
This issue has not been assessed yet.