markjprice / cs11dotnet7

Repository for the Packt Publishing book titled "C# 11 and .NET 7 - Modern Cross-Platform Development Fundamentals" by Mark J. Price
566 stars 206 forks source link

A note about ID generation in the section 'Updating entities' #58

Open MAS-OUD opened 1 year ago

MAS-OUD commented 1 year ago

Regarding the note at the bottom of page 477, it turned out that by deleting the product with ID 78, the next product to be added is again 78, not 79.

markjprice commented 1 year ago

It depends on the database provider so you cannot guarantee that behavior, for example, I believe SQL Server maintains an internal counter but SQLite might not. Also, if you are using SQLite, are you recopying the database each time you restart the console app? Regardless, the note is about the general concept of why my code uses the name and not the ID to identify the added rows, not about specific delete behavior.