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

  • Home
  • SEARCH
  • 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 767169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:10:04+00:00 2026-05-14T17:10:04+00:00

Is there an equivalence in Entity Framework to NHibernate SchemaExport? Given I have a

  • 0

Is there an equivalence in Entity Framework to NHibernate SchemaExport?

Given I have a working Entity-Model, I would like to programmatically initialize a database.

I would like to use this functionality in the setup of my integration tests.

Creating the matching DDL for an Entity-Model would also suffice.

  • 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-14T17:10:05+00:00Added an answer on May 14, 2026 at 5:10 pm

    Yes – given that you’re working with Entity Framework 4 (which is, confusingly enough, the second version…)

    Edit: This is the way to do it with just EF4. In my original post below is described how to accomplish the same thing with the Code-Only approach in EF CTP3.

    How to: Export model to database in EF4
    To export a model to database, right-click anywhere in the designer (where you don’t have an entity) and choose “Generate database from model…” and follow the steps described in the wizard. Voila!


    Original post, targeting EF4 CTP3 and Code-Only: This is code I use in a little setup utility.

    var builder = new ContextBuilder<ObjectContext>();
    
    // Register all configurations you need here
    builder.Configurations.Add(new EntryConfiguration());
    builder.Configurations.Add(new TagConfiguration());
    
    var conn = GetUnOpenedSqlConnection();
    var db = builder.Create(conn);
    
    if (db.DatabaseExists())
    { db.DeleteDatabase(); }
    
     db.CreateDatabase();
    

    It works on my machine (although here I’ve simplified a little bit for brevity…), so if something does not work it’s because I over-simplified.

    Note that, as TomTom stated, you will only get the basics. But it’s pretty useful even if you have a more complicated schema – you only have to manually write DDL to add the complicated stuff onto the generated DB schema.

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

Sidebar

Related Questions

i have been using NHibernate in TDD environment and found it very helpful to
I'm trying to store a document in SQL Server 2008 using the Entity Framework.
I've got two lists of Customer objects, generated from Entity Framework. I need to
Assume you have an entity called Library and each Library can contain Books. It
I have created the POCO class and it's equivalent in edmx file (Category entity
I know this is a bit of a newbie question, but are there equivalents
Is there an equivalent for Interlocked.Exchange for boolean? Such as an atomic exchange of
Is there an equivalent of svn's blame for Perforce on the command line? p4
Is there an equivalent to the Java File method isDirectory() in MFC? I tried
Is there an equivalent of a SQL IN statement in LINQ to objects?

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.