Skip to content

Entity Framework and REST

We will build a new REST API (ASP.NET Core Web API) using Entity Framework.

Pre-requisites and preparation

Required tools to complete the tasks:

  • Windows, Linux, or macOS: All tools are platform-independent, or a platform-independent alternative is available.
  • Postman
  • DB Browser for SQLite - if you would like to check the database (not necessary)
  • GitHub account and a git client
  • Microsoft Visual Studio 2019/2022 with the settings here
    • When using Linux or macOS, you can use Visual Studio Code, the .NET Core SDK, and dotnet CLI.
  • .NET Core 3.1 SDK

    .NET Core 3.1

    Mind the version! You need .NET Core SDK version 3.1 to solve these exercises.

    On Windows, it might already be installed along with Visual Studio (see here how to check it); if not, use the link above to install (the SDK and not the runtime). You need to install it manually when using Linux or macOS.

Materials for preparing for this laboratory:

  • Entity Framework, REST API, Web API, and using Postman
    • Check the materials of Data-driven systems including the seminars
  • Official Microsoft tutorial for Web API

Exercise overview

In this exercise, we will implement the backend of a simple task management web application. The application handles two types of entities: statuses and tasks where a status is associated with multiple tasks (1-* connection). (In the text of the exercises, will use tasks only for referring to this entity of the application.)

If we had a frontend, the application would be a Kanban-board. We will not create a frontend here, only the REST API and Entity Framework + ASP.NET Core Web API server.

Initial steps

Keep in mind that you are expected to follow the submission process.

Create and check out your Git repository

  1. Create your git repository using the invitation link in Moodle. Each lab has a different URL; make sure to use the right one!

  2. Wait for the repository creation to complete, then check out the repository.

    If you are not asked for credentials to log in to GitHub in university computer laboratories when checking out the repository, the operation may fail. This is likely due to the machine using someone else's GitHub credentials. Delete these credentials first (see here), then retry the checkout.

  3. Create a new branch with the name solution and work on this branch.

  4. Open the checked-out folder and type your Neptun code into the neptun.txt file. There should be a single line with the 6 characters of your Neptun code and nothing else in this file.

Creating the database

We will not be using Microsoft SQL Server here, but Sqlite. It is a light-weight relational database management system mainly for client-side applications. Although it is not recommended for servers, we will use it for simplicity. Sqlite requires no installation.

We will define the database schema with code first using C# code. Therefore, we will not need to create the schema with SQL commands.

Back to top