Skip to content

Update concurrency.md#4972

Merged
roji merged 2 commits intodotnet:mainfrom
IvanStoychev:patch-1
Mar 10, 2025
Merged

Update concurrency.md#4972
roji merged 2 commits intodotnet:mainfrom
IvanStoychev:patch-1

Conversation

@IvanStoychev
Copy link
Contributor

Add information about circumstances under which it is possible for a DbUpdateConcurrencyException to be thrown when adding entities.

In the edited document it is originally stated that a DbUpdateConcurrencyException cannot be thrown when adding new entities. However in an SQLite table with constraint UNIQUE("Column Name") ON CONFLICT IGNORE attempting to add a conflicting entity will cause SQLite to simply ignore it and, thus, return fewer rows affected than what EF Core would expect, causing it to raise the exception.

The same is probably true for other RDBMS, for example: Microsoft SQL Server with IGNORE_DUP_KEY = ON but I have not tested it to confirm.

Add information about circumstances under which it is possible for a `DbUpdateConcurrencyException` to be thrown when adding entities.
@roji
Copy link
Member

roji commented Mar 9, 2025

While what you say is technically correct, the situations in which this happens are very, very edge-casey and users have to very intentionally and specifically configure their database in a special way to make this happen. So I'd rather simply add the word generally just before never and be done with it, without going into reasons - docs need to strike a careful balance providing correct information and not overloading readers with information that's irrelevant to 99% of our users.

Does that make sense?

@IvanStoychev
Copy link
Contributor Author

IvanStoychev commented Mar 9, 2025

I understand what you mean and it does make sense. I think we're both right - I can see your reasoning but still believe giving this information to users would be beneficial.

In the end these are your docs, not mine, so if you want me to just add generally - I'll do so.

@roji
Copy link
Member

roji commented Mar 9, 2025

OK, thanks. At the end of the day, this is the first time anyone has raised this AFAIK, and I don't believe the the added sentences would actually help someone in advance in some concrete case. So yeah, I believe just adding generally is sufficient - if we see people struggling with this in the future we can always add more info though.

@roji roji closed this Mar 9, 2025
@roji roji reopened this Mar 9, 2025
Updating with @roji's recommendation.
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@roji roji merged commit 0a4ef68 into dotnet:main Mar 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants