Skip to content

guildenstern70/AspNetCoreAPI

Repository files navigation

ASP.NET Core v10 OpenAPI Template

Codacy Badge License: MIT

A basic Asp.NET Core v10 OpenAPI template. It uses an embedded SQLite database for data persistence.

Screenshot of the API in action

Setup

First, you need to create the database. Follow the instructions in the Entity Framework Core setup section below to install the necessary tools and packages.

Then, run the database migrations to create the SQLite database.

cd AspNetCoreAPI
dotnet ef database update

This creates AspNetCoreAPI/aspnetcoreapi.db. If you need the test database too, copy it to the test project:

cp aspnetcoreapi.db ../AspNetCoreAPI.Test/aspnetcoreapi.db

Build and Run

To build the application run

dotnet build

To run the application run

cd AspNetCoreAPI
dotnet run

Build & Run within a container

Build

docker build -t aspnetcoreapi:1.0 .

Run

docker run -p 3000:3000 aspnetcoreapi:1.0

Entity Framework Core setup

Read all about Entity Framework core here: https://docs.microsoft.com/it-it/ef/core/get-started/overview/first-app?tabs=netcore-cli

dotnet tool install --global dotnet-ef
dotnet add package Microsoft.EntityFrameworkCore.Design

If you need to update the Entity Framework core:

dotnet tool update --global dotnet-ef

Unit Tests

dotnet test

Please note that the tests rely on a different database which contains only test data. The database for tests should be found in the AspNetCoreApi.Test project directory.

About

Basic ASP.NET Core OpenAPI template

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors