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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:33:12+00:00 2026-05-28T03:33:12+00:00

I created a DbContext like so : public class myDB : DbContext { public

  • 0

I created a DbContext like so :

   public class myDB : DbContext
   {
     public DbSet<Party> Parties { get; set; }
     public DbSet<Booking> Bookings { get; set; }
   }

This generated my DataBase and the two tables above..Great

I then decided to add another DbSet into the mix & I got an error:

the model backing the ‘Party’ context has changed since the database was created

I’m aware of the fixes for this using modelbuilder.IncludeMetadataInDatabase = false; and Database.SetInitializer<ClubmansGuideDB>(null);

1) What’s the correct way to add my new classes to the context and have them generated in the DataBase?

2) In my futile attempts to solve this myself I deleted the tables and tried to re-run the app with no success I then deleted the full database and re-run and it doesn’t re-generate the DB. How can I start from scratch – is there some cache somewhere?

  • 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-28T03:33:13+00:00Added an answer on May 28, 2026 at 3:33 am

    I believe you’re looking for:

    Database.SetInitializer<ClubmansGuideDB>(new DropCreateDatabaseIfModelChanges<ClubmansGuideDB>());
    

    As of EF 4.1 and above.

    Note that this assumes you have permission to even drop your database. I do this locally for ease of development but disable it in staging/production (I do a manual Schema Compare and push my changes).

    By the way, for testing, if you need to force recreate the database, you can do:

    using (var context = new ClubmansGuideDB()) {
        context.Database.Initialize(force: true);
    }
    

    (using if you don’t already have a reference to your DB)

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

Sidebar

Related Questions

This is how my data model for USER looks like public class User {
I have the following class: public class AuthContext : DbContext { public DbSet<Models.Permission> Permissions
I'm using the EF4.1 DbContext code generation, which creates POCO entities like this: public
Created .NET WCF service, tested it - works. Generated schemas from Data and service
I created a single page (with code behind .vb) and created Public intFileID As
I created a Rails application normally. Then created the scaffold for an event class.
I've already read some articles about this matter, but I'd like to ask once
I have like 50 of this 'Type models' (as i call them), and they
I have a model that looks like this (well not really but it has
I am reading this E.F. Team Blog's this series http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-1-introduction-and-model.aspx At many places i

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.