by Santhakumar Munuswamy

Posted on 03 October 2016

ASP.NET Core

In this article, we will discuss how we can develop the user management application using ASP.Net Core with Entity Framework Core in Windows. As we discussed understanding about ASP.Net Core with hello world application on Windows in my previous articles. If you want to learn ASP.Net Core and its features, you can read the below link:

In this article, we will discuss in detail steps:

Prerequisite

Create an ASP.NET Core Web Application on Windows

How to install the Entity Framework Core

How to add Entity Framework Core package to project.json file

Create a model class

How to register your context with dependency injection

How to create our database

How to create our controller

How to create view

How to run the user management application

Prerequisite

Visual Studio 2015

.NET Core 1.0

You want to download and install the free community edition of Visual Studio 2015. You can download from the Visual Studio . Furthermore, you can download .NET Core 1.0 for windows platform from .Net website.

Create an ASP.NET Core Web Application on Windows

Open Visual Studio 2015. Go to File menu, point to new and click new project. New Project Window will open, you can select an installed template like “.NET Core” in Visual C# Template and then select the Asp.Net Core Web Application (.NET Core) and type Project Name ASP.NETCoreWithEFCore. Choose the project location path and click OK button.





You can select a template “Web Application” and click OK button





Now, you can see ASP.NETCoreWithEFCore project structure, as shown in the screen shot, given below





How to install the Entity Framework Core

We are going to use EF Core and install the package for the database provider from NuGet Package Manager Console in Visual Studio 2015. We will see in detail how to install EF Core for SQL Server database using the command as below steps.

Go to Visual Studio Tools, point to NuGet Package Manager and then click Package Manager Console menu

After sometimes, Successfully Package Console Manager which is ready

Type Install-Package Microsoft.EntityFrameworkCore.SqlServer and Enter

After sometimes, Successfully installed Microsoft.EntityFrameworkCore.Sqlserver 1.0.1 Then, we have to wait some times for restoring the packages.









Type Install-Package Microsoft.EntityFrameworkCore.Tools –Pre and Enter

After sometimes, Successfully installed Microsoft.EntityFrameworkCore.Tool 1.0.0-preview2-final. Then, we have to wait some times for restoring the packages.



How to add Entity Framework Core package to project.json file Now, you can see in detail how to configure the entity framework core package in project.json file. Go to Solution Explorer and then open project.json file

Now you can verify the tools section whether if already entity framework core package configured or not and if it is not configured the particular package.

Now you can add the “Microsoft.EntityFrameworkCore.Tools”: “1.0.0-preview2-final”







