Database Reference
In-Depth Information
Chapter 4
Using Entity Framework in
ASP.NET MVC
ASP.NET is a free Web framework that supports three different technologies to create websites and Web applications;
that is, Web Pages, Web Forms, and MVC. Although MVC is a very popular and well-established concept designed to
be used as a pattern in software development, MVC in ASP.NET framework is fairly new technology. The latest version
of ASP.NET MVC 4 was released in 2012. Since the release of the initial version in 2008, it has become a popular means
for ASP.NET Web Forms development. Therefore, this chapter shows you recipes made only with ASP.NET MVC 4 and
Entity Framework. Two other forms of ASP.NET technology—ASP.NET Web Forms and ASP.NET Web Pages—are not
covered in this chapter.
The recipes in this chapter cover everything from building an insert, update, delete, and list page to
implementing search functionality.
Each of the recipes in this chapter is shown using an ASP.NET MVC 4 Web application project in Visual Studio
2012. We've tried to keep things simple by not including all of the extra code that comes with the default project
template.
4.1. Building CRUD Operations in an ASP.NET MVC Page
The create, read, update, and delete (CRUD) operations are fundamental to almost every software application. We are
going to implement these operations in this section using ASP.NET MVC.
Problem
You want to build an ASP.NET MVC page that allows inserting, updating, deleting, and reading from your model.
Solution
Let's say you have a Web application that manages the list of software apps for a mobile device. You have a model like
the one shown in Figure 4-1 .
 
Search WWH ::




Custom Search