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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:29:40+00:00 2026-05-27T19:29:40+00:00

I am working with entity framework with code fist design pattern. First of all

  • 0

I am working with entity framework with code fist design pattern.
First of all I created two tables classes …

using System.Data.Entity;
public class CyclingClubContext:DbContext
{   
public DbSet<CycleType> CycleType { get; set; }
public DbSet<CycleModel> CycleModel { get; set; }
}

When I run my project,
It create two tables at database which is auto-generated as CyclingClub.sdf file.
Then , I need to add another entity class.
So, After I created new my entity class, I modify Context class like that …

using System.Data.Entity;
public class CyclingClubContext:DbContext
{   
public DbSet<CycleType> CycleType { get; set; }
public DbSet<CycleModel> CycleModel { get; set; }
public DbSet<SideMenu> SideMenu { get; set; }
}

Then, I build my project, but it still show that build success message.
But when I run my project, problem start happen by showing message that

[InalidOperationException was unhandled by user code.]

The model backing the 'CyclingClubContext' context has changed since the database was  created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

So now I have more than one question.

1)How can I solve this error?

2)Whenever we need to add new entity class, do we need to delete existing database first
and recreate the database as error message already suggest me?

3)If we need to delete first and recreate the new database , then I afraid that my
existing record(s) will lose after recreate the new database. What will be the best solution?

4)Is SDF file really reliable one when we want to go enterprise level? If so let me know the reason why?

5)MDF file and SDF file , which one is better for enterprise level which need to deal with
large volume of data and multiple users access at single time?

6)Is this possible to use MDF file in entity framework code first design pattern?
If so let me know the reference links which showing how?

Every suggestion will be really appreciated.

  • 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-27T19:29:41+00:00Added an answer on May 27, 2026 at 7:29 pm
    1. The error exactly says how you should solve it. At start of your application you can set initializer of the database and control if it should be automatically recreated and when.
    2. With current implementation EF code-first can only create whole database with all tables so indeed if you add new entities or modify existing entities EF can use them only if it deletes old database and recreate it. This will change in EF 4.3 which should contain EF Migrations. EF Migrations will offer incremental building of the database.
    3. Yes. With currently available initializers your data will be lost. Initializers are currently more for development. You can derive custom initializer and override Seed method to fill your newly created database with some initial data.
    4. SDF file is for SQL Server Compact edition. It is for very small databases. For example for local storage of WPF/WinForm application or as simple configuration database for web application. It is not for large data sets of intensive usage.
    5. MDF file is for SQL Server. If you are going to build enterprise application working with large data sets you should go to full (commercial) edition of SQL server. SQL Express has limitations on CPU usage and database size for 2008 R2 is limited to 10GB (former versions has much worse limitation).
    6. Yes it is possible. You just have to correctly define connection string for big SQL server and you must have permissions to create databases on that server.

    You can think that my answers are not detailed enough but that is because you are asking too many questions in one thread.

    Just follow this set of articles to learn about code first. It targets pre-release version but almost all content should be valid.

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

Sidebar

Related Questions

I'm working on an MVC site with Entity Framework Code First, using Ninject for
I'm using Entity Framework Code First and whilst I have working code, I'm having
I have been using Entity Framework CTP with Code-First as in this tutorial by
I am working on a simple web application made using Entity Framework 4.1 Code
Background We have a WinForms application with Entity Framework 4.2 code-first / FluentAPI using
Is there a way in Entity Framework 4 (using CTP4 and Code First if
I'm using the Entity Framework version 4.2. There are two classes in my small
Using the Entity Framework Code First paradigm I have defined the following objects and
Does WCF Data Services support working with Entity Framework Code First (4.1)? It seems
I currently working on a application that use Entity Framework 4.1 (code first) and

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.