I using ORM telerik open access in my project. I can use it to create and add data to my database.
Now i want to clean all data from my database. I can do it by delete data from each table but it will take long code. I have google how to clean it using DBContext and found nothing. There another way to clean database but not looping to call delete function for each table in my DB?
(SQL SERVER only) You could use the following sql script to clean up the data in your database:
/* 1. Disable all constraints and triggers*/ exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
/* 2. Delete all of table data */ exec sp_MSforeachtable 'DELETE ?'
/* 3. Enable all constraints and triggers */ exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL' exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
/* 4. Reset tables identity */ exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END'