You can run your own SQL query to replace the values, for example:
update Navigation set valuecolumn = case when id=1 then 'value2' when id=2 then 'value1' end where id in (1,2)
However, the Entity Framework cannot do this because it is beyond the scope of ORM. It simply executes successive update instructions for each changed object, as described in its Ladislav answer.
Another possibility would be to abandon the UNIQUE in your database and rely on the application to correctly apply this constraint. In this case, EF may save the changes just fine, but depending on your scenario, this may not be possible.
Golfwolf
source share