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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:48:17+00:00 2026-06-18T05:48:17+00:00

I have some old tables which I have added them to the project by

  • 0

I have some old tables which I have added them to the project by reverse engineering to use them as code first.

Something like this:

public class User
{
    public string Name { get; set; }
    public int Id { get; set; }
}

public class Profile
{
    [Key, ForeignKey("User")]
    public int  Id { get; set; }
    public string Name { get; set; }

    public virtual User User { get; set; }
}

public class EFDbContext : DbContext
{
    public DbSet<User> Users{ get; set; }
    public DbSet<Profile> Profiles { get; set; }
}

Here if my old table User was exist then Entity Framework doesn’t create other tables such as Profile table.

My Question How can I specify which table should be created if doesn’t exist?

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

    Have you checked this answer?

    EF4 Code First create new table

    Unless you drop and re-created you full database, I don’t think it’s possible.

    Setting an Initialization Strategy

    In the next section we are going to start changing our model which in turn means the database schema needs to change as well. Currently there is no ‘out of the box’ solution to evolve your existing schema in place. Database evolution is something we are currently working on and a sample of the direction we are heading is provided in a recent design blog post.

    There is however the opportunity to run some custom logic to initialize the database the first time a context is used in an AppDomain. This is handy if you want to insert seed data for test runs but it’s also useful to re-create the database if the model has changed. In CTP5 we include a couple of strategies you can plug in but you can also write custom ones.

    Add a using statement for System.Data.Entity.Database at the top of Program.cs

    using System.Data.Entity.Database;
    

    For the walkthrough we just want to drop and re-create the database whenever the model has changed, so at the top of the Main method in my Program class I’ve added the following code

    DbDatabase.SetInitializer<ProductContext>(
    new DropCreateDatabaseIfModelChanges<ProductContext>());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some old code that uses qsort to sort an MFC CArray of
I have some old code (an old but still maintained VB6 application) that from
I have some old fortran77 codes, and I convert them into .pyd files using
We have some code kicking around that uses this old internal Sun package for
I have 2 applications. App1 is some old selfmade php project, not using Zend.
I have two already-existing tables which look (in part) roughly like this: CREATE TABLE
I have an old table that I'm working with, which looks like this: +------------------+--------------+------+-----+---------+-------+
I have some old content containing tables with their width specified with an HTML
I have some old branches in my git repository that are no longer under
I have some old fortran 77 I'm trying to port to gcc on Windows.

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.