This code adds a simple extension method to any DbContext that will massively delete all the data in any table referenced in the entity framework query that you provide. It works by simply extracting all the names of the tables involved in the query, and tries to delete the data by sending the SQL query "DELETE FROM tablename", which is common to most types of databases.
To use, simply do the following:
myContext.BulkDelete(x => x.Things);
which will delete everything in the table associated with the Things object store.
The code:
using System.Linq; using System.Text.RegularExpressions; namespace System.Data.Entity { public static class DbContextExtensions {
BG100 source share