title: On error resume next for Microsoft SQL, when using sp_MSforeachtable?
body: <p>I am making a script that deletes all tables before recreating them with the Entity Framework. I did this by implementing an IDatabaseInitializer that does this for me.</p>
  
  <p>However, as you may have guessed, when trying to delete a table that has a foreign key constraint, it fails misserably, and the whole script terminates.</p>
  
  <p>How can I prevent this? Here's how I am dropping the tables.</p>
  
  <pre><code>context.Database.ExecuteSqlCommand("EXEC sp_MSforeachtable @command1 = \"DROP TABLE ?\"");
  </code></pre>
  
  <p>Now, I put this into a while-loop that keeps executing until all tables are removed. However, since this command deletes all tables in order, and fails when the first table can't be removed, this script is not working.</p>
  
  <p>Is there any way to make Microsoft SQL Server ignore any errors, and resume table deletion with the next entry instead?</p>