Jump to content

Code first or Db first which approach is acceptable in MVC ?

Featured Replies

Overview

In this walkthrough you will build pieces of a blogging application. The walkthrough will not result in a fully functional blogging application, but instead it will use the blog classes to demonstrate code first’s features. You will:

  • Define a set of classes to represent the entities for a blog — Blog, Post and Comment.
  • Reference the Entity Framework code first assembly.
  • Create a DbContext to manage the Blog classes and data access.
  • Build a simple ASP.NET MVC 3 application that will let you view, add, edit and delete blogs.
Creating the MVC Application

For this demo, all of the code will live inside of an MVC 3 project so the first step will be to create that project. You’ll use a template that will set up much of the structure for the application.

If you have not installed MVC 3 you can find the download and instructions at http://www.asp.net/mvc/mvc3.

  1. In Visual Studio 2010, add a new project by selecting the File menu, then New and then Project.
  2. In the Search Installed Templates text box (top right), type MVC 3 to filter down the list of project templates.
  3. Select ASP.NET MVC 3 Web Application using your language of choice. This walkthrough will use C# code, but you can find both C# and Visual Basic versions in the sample solutions download.
  4. Name the project MVC3AppCodeFirst and then click OK.
  5. In the New ASP.NET MVC 3 Project wizard, choose Internet Application.
  6. Leave the default values of the other options and click OK.

In answer to the OP, it doesn't matter really. In our team, for example, developers routinely stub in data to test their code with while db development is ongoing by our db team. The code and db are integrated prior to going to UAT.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.