Example service including c# .net core code

Using Visual Studio, create a new project and choose “ASP .NET Core Web Application”

Visual Studio Template

Click “Next” then give your API a Name – we’ll use TestApi, then click “Create”

Visual Studio Template

Select API and the click “Create”

Select API

Add API Data Entity

We will use the .NET Core Entity framework to add our entity. First we need to create the template entity class. Right click on the project and select “Add Folder” and name the folder “Models”

Add a new class to the folder and define the Data Entity to be created – in this case we’ll use “Student” as an example

Add API Controller

Right click on the project and select “New Scaffolded Item”, then “API Controller, with Actions, Using Entity Framework”

Select the Data Entity to be used – the “Student” class created above, then specify a new data contect class

The Entity framework context and controller will now be created automatically.

Add the following lines to the StudentContext class to automatically create the DB table

All examples and code by Roland Kamsika