You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EF then try to sort entities alphabetically on insert thus getting into constraint violation
You can check issue here dotnet/efcore#11686
This issue lead me to PR dotnet/efcore#25874 where inserted entities are ordered using StringComparer.Ordinal
After digging source code found the piece of code that cause this
case AddEventsAction(var events):
_store.Context.AddRange(events);
break;
Proposed solution:
As a solution I can only think of Bulk insert wrapped in transaction. Maybe you'll find a better way
The text was updated successfully, but these errors were encountered:
We were able to reproduce the issue in our tests and saw that EF Core indeed does not preserve insertion order, leading to a violated ConsecutiveIndex constraint while using Postgres. For reasons unknown to me, the same error does not occur in SQL Server.
I've linked a proposed solution PR, but we might investigate alternative solutions before merging the PR.
Current behavior:
When using multiple
Apply
methodsEFCore
provider doesn't preserve their order on insert.My code that fails
EF then try to sort entities alphabetically on insert thus getting into constraint violation
You can check issue here dotnet/efcore#11686
This issue lead me to PR dotnet/efcore#25874 where inserted entities are ordered using
StringComparer.Ordinal
After digging source code found the piece of code that cause this
Proposed solution:
As a solution I can only think of
Bulk insert
wrapped in transaction. Maybe you'll find a better wayThe text was updated successfully, but these errors were encountered: