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 8202781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:18:45+00:00 2026-06-07T07:18:45+00:00

I created some tables in an .edmx file and have been generating the database

  • 0

I created some tables in an .edmx file and have been generating the database by selecting “Generate Database From Model” and manually executing an .edmx.sql file on the database to build the tables.

Now, however, I am creating a setup dialog that allows the user to connect the program up to their own database. I thought running context.CreateDatabase would be good enough to create the database, along with the tables, but the tables are not created.

What is the preferred method for creating the database and tables when the user specifies their own server and database to use, when originally starting with a model?

  • 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-06-07T07:18:48+00:00Added an answer on June 7, 2026 at 7:18 am

    Ok, I figured out a way of creating the tables and database (not necessarily the best way). The result of CreateDatabaseScript can be executed:

    // create the database
    db.CreateDatabase();
    // grab the script to create the tables
    string createScript = db.CreateDatabaseScript();
    // execute the script on the database
    db.ExecuteStoreCommand(createScript);
    

    You have to do some checking to make sure the tables and database aren’t created already, otherwise the application will crash.

    I’m going to take a stab at switching my project over to code-first though. Hopefully the above will help anyone looking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I right-click in a .EDMX file and click Generate Database From Model ,
I made a blog database and created some tables in it. I have wriTten
I have this EF database-first EDMX file that I created it with a local
I have a database that I had imported and accidentally created some tables as
I have created a database test with some tables in MS SQL Server 2008
iv created a database with some tables and populated them using SQL server 2008,
I use SQL server 2008 and I have created some tables. I want to
I have an applicaton that contains some tables that are auto-generated from Grails domain
I have a SQLite database that is created by reading some data in PDF
I have some tables like this: USERS TABLE: | id | created | active

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.