Getting started with ASP.NET Core MVC and Entity …

Getting started with Core MVC and Entity Framework Core using Visual Studio (1 of 10)

By Tom Dykstra and Rick Anderson

The Contoso University sample web application demonstrates how to create Core 1.1 MVC web applications using Entity Framework Core 1.1 and Visual Studio 2017.

The sample application is a web site for a fictional Contoso University. It includes functionality such as student admission, course creation, and instructor assignments. This is the first in a series of tutorials that explain how to build the Contoso University sample application from scratch.

Download or view the completed application.

EF Core 1.1 is the latest version of EF but does not yet have all the features of EF 6.x. For information about how to choose between EF 6.x and EF Core 1.0, see EF Core vs. EF6.x. If you choose EF 6.x, see the previous version of this tutorial series.

Note

For the Visual Studio 2015 version of this tutorial, see the VS 2015 version of Core documentation in PDF format.

Prerequisites

Visual Studio 2017 with the and web development and .NET Core crossplatform development workloads installed.

Troubleshooting

If you run into a problem you can't resolve, you can generally find the solution by comparing your code to the completed project. For a list of common errors and how to solve them, see the Troubleshooting section of the last tutorial in the series. If you don't find what you need there, you can post a question to for Core or EF Core.

Tip

This is a series of 10 tutorials, each of which builds on what is done in earlier tutorials. Consider saving a copy of the project after each successful tutorial completion. Then if you run into problems, you can start over from the previous tutorial instead of going back to the beginning of the whole series.

The Contoso University web application

The application you'll be building in these tutorials is a simple university web site.

Users can view and update student, course, and instructor information. Here are a few of the screens you'll create.

The UI style of this site has been kept close to what's generated by the built-in templates, so that the tutorial can focus mainly on how to use the Entity Framework.

Create an Core MVC web application

Open Visual Studio and create a new Core C# web project named "ContosoUniversity".

? From the File menu, select New > Project. ? From the left pane, select Templates > Visual C# > Web. ? Select the Core Web Application (.NET Core) project template. ? Enter ContosoUniversity as the name and click OK.

? Wait for the New Core Web Application (.NET Core) dialog to appear ? Select Core 1.1 and the Web Application template.

Note: This tutorial requires Core 1.1 and EF Core 1.1 or later -- make sure that Core 1.0 is not selected.

? Make sure Authentication is set to No Authentication. ? Click OK

Set up the site style

A few simple changes will set up the site menu, layout, and home page.

Open Views/Shared/_Layout.cshtml and make the following changes:

? Change each occurrence of "ContosoUniversity" to "Contoso University". There are three occurrences.

? Add menu entries for Students, Courses, Instructors, and Departments, and delete the Contact menu entry.

The changes are highlighted. htmlCopy

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download