Book Image

ASP.NET Core 2 Fundamentals

By : Onur Gumus, Mugilan T. S. Ragupathi
Book Image

ASP.NET Core 2 Fundamentals

By: Onur Gumus, Mugilan T. S. Ragupathi

Overview of this book

The book sets the stage with an introduction to web applications and helps you build an understanding of the tried-and-true MVC architecture. You learn all about views, from what is the Razor view engine to tagging helpers. You gain insight into what models are, how to bind them, and how to migrate database using the correct model. As you get comfortable with the world of ASP.NET, you learn about validation and routing. You also learn the advanced concepts, such as designing Rest Buy (a RESTful shopping cart application), creating entities for it, and creating EF context and migrations. By the time you are done reading the book, you will be able to optimally use ASP.NET to develop, unit test, and deploy applications like a pro.
Table of Contents (14 chapters)

Using Entity Framework in ASP.NET MVC Applications


There is not much difference between using Entity Framework in a console application and the ASP.NET MVC application. Now, we are going to build a simple application with a single screen, as shown in the following screenshot.

In this screen, we will have a form where the user will enter the information about the employee; once the user submits the form, the information will be saved to the database as shown in the following screenshot:

We can create a simple model for the employee. We need to build a ViewModel for this view, as we need to get the employee information from the user and we also need to show a list of employees on the same screen.

The following are the step-by-step instructions to create the application for the previously mentioned objective:

  1. Create an ASP.NET Core project in Visual Studio by selecting an empty ASP.NET Core Web application.
  2. All the Entity Framework packages we need come baked in, so there is no need to install anything...