This repository contains the backend day task for our onboarding process. It's a simple School App API that currently has the teacher model implemented. Your task is to work on implementing the student model, which involves basic CRUD operations.
Follow these instructions to set up your development environment:
Before you begin, ensure you have the following installed:
-
.NET SDK: Follow the steps in the Hello World Tutorial to install and set up .NET.
-
PostgreSQL: Follow the steps outlined in the Prisma PostgreSQL Setup Guide to install and configure PostgreSQL.
-
Install PostgreSQL: If you haven't already, you can install PostgreSQL on Linux using the following commands (for Ubuntu):
sudo apt update sudo apt install postgresql postgresql-contrib
-
Start PostgreSQL: After installation, start the PostgreSQL service:
sudo service postgresql start
-
Create a Database User: By default, PostgreSQL creates a user called
postgres
. You can switch to this user and create a new database user with the following commands:sudo -i -u postgres createuser --interactive
Follow the prompts to create a new user.
-
Create a Database: Still as the
postgres
user, you can create a new database:createdb your_database_name
-
Download and Install PostgreSQL: Download the PostgreSQL installer for Windows from the official website, and follow the installation instructions.
-
Start PostgreSQL: After installation, start the PostgreSQL service from the Windows Services Manager, or it might start automatically.
-
Create a Database User: By default, PostgreSQL creates a user called
postgres
. You can open the SQL Shell (psql) from the Start menu and run the following command to create a new user:CREATE ROLE your_username WITH LOGIN PASSWORD 'your_password';
Replace
your_username
andyour_password
with your desired username and password. -
Create a Database: In the SQL Shell, you can create a new database:
CREATE DATABASE your_database_name;
Replace
your_database_name
with the desired name of your database.
dotnet tool install --global dotnet-ef
dotnet ef migrations add "initial migration"
dotnet ef database update
After creating the database, you'll need to update the connection string in your application's configuration to point to your PostgreSQL database. Locate the connection string in your project (typically in the appsettings.json
or appsettings.Development.json
file) and modify it like this:
"DefaultConnection": "Host=localhost;Port=5432;Database=your_database_name;Username=your_username;Password=your_password;"
Host
: Uselocalhost
if your PostgreSQL server is running locally.Port
: Default PostgreSQL port is 5432.Database
: Replace with the name of the database you created.Username
: Replace with the username you created.Password
: Replace with the password for the username.
If you encounter issues with PostgreSQL installation or prefer an in-memory database, you can use SQLite by switching to the In_memory
branch of this repository. SQLite is a self-contained, serverless, and zero-configuration SQL database engine.
In case you encounter issues with package installation or need to manually install a package, you have a couple of options:
-
Visual Studio: Install the "NuGet Gallery" extension if you're using Visual Studio. Follow the instructions to get the desired package.
-
Command Line (Terminal): You can also use the command line to install packages. Run the following command to add a package. For instance, to add the SQLite package, use:
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Please note that most of the required packages should already be set up in this project. Manually installing packages is only necessary if you encounter any issues.
Your task is to implement the student model in the School App API, including basic CRUD (Create, Read, Update, Delete) operations. You can start by forking this repository and working on your solution.
Feel free to reach out if you have any questions or encounter any difficulties during the task.