I am trying to swap a value in a unique column for two (or more rows). For instance:
Before updating:
After update:
I am using Entity Framework. These changes occur in one commit for the same context. However, when I try this update, I always get a unique violation of restrictions. Does EF not use a transaction?
For completeness, here is a snippet of my table:
[FeeSchemeId] UNIQUEIDENTIFIER NOT NULL,
[SortPosition] INT NOT NULL,
UNIQUE (FeeSchemeId, SortPosition)
I am trying to update the column "SortPosition". The code here is a bit complicated, but I can assure you that it is the same context with one final commit. An error is only raised when EF tries to write to the database.
UPDATE:
- SQL Server Profiler, , EF UPDATE . EF SaveChanges()?
> -
2:
, EF . SQL Profiler .