How to do it...

We will query the Book table in our SQL Express database:

  1. First, we will create three folders: Controllers, Models, and Views.
  2. Next, we add the following NuGet packages to the dependencies to the project:
"Microsoft.AspNetCore.Server.IISIntegration","Microsoft.AspNetCore.Server.Kestrel","Microsoft.AspNetCore.Mvc","Microsoft.AspNetCore.Razor.Tools","Microsoft.Extensions.Configuration.EnvironmentVariables","Microsoft.Extensions.Configuration.Json","System.Data.Common","System.Data.SqlClient","Dapper"
  1. Next, let's create an appsettings.config file to add our database connection string and add the following code:
{  "ConnectionStrings": {    "CookBookConnection":  "Data Source=PC-HOME\\SQLEXPRESS;Initial Catalog=CookBook;Integrated ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.