Created
April 1, 2015 11:46
-
-
Save diffused/90d329ac8f2878c39661 to your computer and use it in GitHub Desktop.
EF + Sql Server wipe data in all tables listed in __MigrationHistory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context.Database.ExecuteSqlCommand("sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'"); | |
context.Database.ExecuteSqlCommand("sp_MSForEachTable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0)) DELETE FROM ?'"); | |
context.Database.ExecuteSqlCommand("EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment