ttajic
10/24/2016 - 7:07 AM

Execute plain SQL in Entity Framework

Execute plain SQL in Entity Framework

   //As EF does not have delete on whole table (just per row) this comes in handy
   using (var context = new DatabaseEntities())
    {
        // delete existing records
        context.ExecuteStoreCommand("DELETE FROM YOURTABLE WHERE CustomerID = {0}", customerId);
    }