-
Install Required Dependencies:
sudo apt update sudo apt install -y apt-transport-https ca-certificates software-properties-common
-
Add Microsoft Package Repository:
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb
-
Install .NET SDK:
sudo apt update sudo apt install -y dotnet-sdk-8.0
-
Verify Installation:
dotnet --version
- Open VS Code (or Cursor) and go to the Extensions panel.
- Search for 'C#' (by OmniSharp) and install it.
- Update the package index:
sudo apt update
- Install MySQL Server:
sudo apt install -y mysql-server
- Install the EF Core Tool globally:
dotnet tool install --global dotnet-ef
- Add the EF Core provider for MySQL:
dotnet add package Pomelo.EntityFrameworkCore.MySql
- Create a new ASP.NET Core project:
dotnet new webapi -n MyApi cd MyApi
- Run the application:
dotnet run
- Add the Swagger package:
dotnet add package Swashbuckle.AspNetCore
- Configure Swagger in
Startup.cs
orProgram.cs
:- Add in
ConfigureServices
:services.AddSwaggerGen();
- Add in
Configure
to enable Swagger UI:app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
- Add in
- Test the API using Postman, Insomnia, or cURL.
- Plan for deploying the API to a hosting service (e.g., Azure, AWS, DigitalOcean, or Heroku).