Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:16:32+00:00 2026-05-25T01:16:32+00:00

I have a method to delete all my tables. I’d like to know if

  • 0

I have a method to delete all my tables.

I’d like to know if I can:

(1) Iterate over the meta data in the model to accomplish the same thing?

(2) Reset the Identity Insert counts along the way?

Note: I don’t want to delete the entire database, just all the tables.

Here’s the code I want to convert to a generic loop:

    public void Delete() {
        using (var db = this.DirectAgentsEntities)
        {
            db.StartingBalances.DeleteObjects(db.StartingBalances);
            ...
            db.RecordSourceTypes.DeleteObjects(db.RecordSourceTypes);
            db.SaveChanges();
        }
    }
static class Extensions {
    static public void DeleteObjects<TEntity>(this ObjectSet<TEntity> set, IEnumerable<TEntity> data) where TEntity : class {
        foreach (var entity in data)
            set.DeleteObject(entity);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:16:33+00:00Added an answer on May 25, 2026 at 1:16 am

    It may be simpler to:

    • drop the database
    • recreate the database
    • create the tables

    The edmx file is just xml, so you could loop through it, then for each table you find:

    • Delete from Tablename
    • DBCC CHECKIDENT (Tablename, reseed, 0)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app i have reset button which delete all the data of tables
I have class method that returns a list of employees that I can iterate
We have some methods that call File.Copy, File.Delete, File.Exists, etc. How can we test
I have a method that can return either a single object or a collection
I am creating tables with the appendchild method. They contain checkboxes. I would like
I have a method that virtually deletes ALL messages of a current_user and by
For my iPhone app, I have an editable (for delete) table view. I'd like
I have two tables, in which one user can have several contacts: User(UserId, UserName)
There is a lot of (older) related data spread over many tables in our
When manipulating data using Linq, how often does the SubmitChanges() method have to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.