Resetting databases: data vs metadata
Chapter 12: LINQ beyond collections: 12.1.2
Last updated: 1/1/2009
In section 12.1.2 on page 319, I note two different ways of resetting the database - one issuing direct SQL commands, and the other using LINQ to SQL to load everything and then delete each entry.
It should be noted that although these have the same effect in terms of the data stored directly in the tables, the SQL code (in CleanDatabaseQuickly.cs) also resets some metadata in the table - namely the identity values. This can be important occasionally - e.g. in unit tests which might expect the database to be in an absolutely known state. Most production code shouldn't care what
ID values are generated, of course.