Entity Framework SaveChanges Cancel ID

I had a question about the behavior of the Entity Framework when executed SaveChanges.

I have an entity that has an Identity Column and just understand that when I call SaveChanges(for a new insert) and it fails, my Identity column in my database grows.

I used to have an Identity column value of 7, and I debugged my code, and the method was SaveChangesrun 5 times, because I skipped to insert the desired value, and when it worked, I noticed that the identifier column value was now 13.

enter image description here

Is this normal behavior? Is there a way to avoid increasing the value of the identifier column when the Entity Framework cannot commit in my database?

+4
1

Sql, Entity Framework. Dbreseed , , Identity was wasted.check this So question RESEED , . Bigint

0

All Articles