Bug #110220 Deleting non existent entity (with concurrency check) from DB does NOT throw ex
Submitted: 27 Feb 2023 8:20 Modified: 27 Feb 2023 10:13
Reporter: Diego Acosta Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:7.0.0 OS:MacOS (Monterey)
Assigned to: CPU Architecture:Any
Tags: ConcurrencyCheck, EF Code First, EFCore, mysql8.0.31, net6

[27 Feb 2023 8:20] Diego Acosta
Description:
GOAL: Being able to delete an entity from the DB using EF. If the entity does NOT exist, throw a DbUpdateConcurrencyException

PROBLEM/ERROR: The DbContext.SaveChanges does NOT throw an exception when no row was affected by the write operation. 
I've tried multiple configurations using the EF fluent api or Data Annotations, and none of them makes the context to throw the exception.

TESTED WITH:
- MySQL: 8.0.31 (MySQL Community Server - GPL)
- MySql.EntityFrameworkCore Version 7.0.0
- Net 6

How to repeat:
I've created a repo with a sample app to reproduce the error: 
https://github.com/diegoacosta-sage/ef-core-mysql-dettaeched-entities-poc
[27 Feb 2023 10:13] MySQL Verification Team
Hello Diego Acosta,

Thank you for the report and test case.

regards,
Umesh