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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:18:22+00:00 2026-06-09T10:18:22+00:00

So far I’ve been working with MVC3 with Linq to Sql so that all

  • 0

So far I’ve been working with MVC3 with Linq to Sql so that all models have been pre-generated and I would create database myself then move the tables onto the dbml editor and if I wanted to change the table I’d remove the entity on the editor and drag it on again. It works perfectly fine, but I’ve noticed that Microsoft is moving on with EF a lot, and that I should probably learn that too.

So, after reading some articles, I am totally confused. I wanted to start with Code First approach, which as I understood, makes the developer create the model for the entity first and then the model creates the database. The most confusing thing here is that when I change the model, and at the runtime when my models are being compared to the entities, if it determines that two aren’t the same, it drops all tables and recreates them. If that’s the case, how do I persist my data? How do I store all my tables so that they don’t get dropped? Should I use “Database First” approach instead?

Please help. Thanks!

  • 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-09T10:18:24+00:00Added an answer on June 9, 2026 at 10:18 am

    You are completely right in looking at the Entity Framework instead of Linq To Sql. Microsoft focuses on EF and that’s the way to go. The Entity Framework has three options:

    • Database First
    • Model First
    • Code First

    With database first you have an existing database that you use to create a model for you. This is done in a designer that will show you how your model looks like and where you can modify the mapping between your entities and the database.

    Model first starts with an empty designer. You create your entities and then you let the Entity Framework create a database schema for it.

    With Code First you don’t have a designer. Instead you create your entities in code and at runtime the Entity Framework creates a mapping from your entities to a database. This is done by some conventions (like each entity to its own table, Id properties as primary keys) and by custom mapping that you can add.

    From a Linq To Sql background, the model first/database first may sound familair to you. Code First is a new way that appeals to people who want to create a clean domain model that’s purely POCO. They focus on the code, not the database.

    You can experiment with all three. They all have a common base and some extra features.

    Code First will have quite a lot of options when creating your database. Here you can find some info that can help getting started. The reason you see that your database is being dropped and recreated each time is because of a Database Initializer. You have several options for creating, recreating and updating your database.

    In a development environment it’s probably the easiest to drop and create your database on each model change. You can also seed your database with some initial test data. In a production environment you will use Code First Migrations to migrate your database on each model change so your data is preserved.

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

Sidebar

Related Questions

So far all the sites I have made have been in PHP, I'm thinking
So far all the mistakes I've been making have been small things I'm missing,
So far I have only been updated a view from within its controller. I
So far i have the following code, but it doesn't seem to be working,
So far I have not been able to find an answer, but I wanted
So far I have been suggesting new features to http://delphi.uservoice.com Since it is managed
So far I have been using in tutorials, examples and sample code only packages
So far I have encountered adjacency list, nested sets and nested intervals as models
So far, I have been storing the array in a vector and then looping
So far I've been setting up redirects for single pages on my ASP.NET site

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.