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 ApplicationFor 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.
In Visual Studio 2010, add a new project by selecting the File menu, then New and then Project. In the Search Installed Templates text box (top right), type MVC 3 to filter down the list of project templates. 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. Name the project MVC3AppCodeFirst and then click OK. In the New ASP.NET MVC 3 Project wizard, choose Internet Application. Leave the default values of the other options and click OK.