Giter VIP home page Giter VIP logo

minimalapi.net8's Introduction

Minimal API with Entity Framework Core and SQLite

This project is a Minimal API built with ASP.NET Core that uses Entity Framework Core for data access and SQLite as the database. The API manages User and Order entities and includes basic CRUD operations.

Features

  • Minimal API structure using ASP.NET Core.
  • Entity Framework Core for data access.
  • SQLite as the database.
  • CRUD operations for User and Order entities.
  • Swagger for API documentation and testing.

Getting Started

Prerequisites

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/minimal-api-database.git
    cd minimal-api-database
  2. Restore the dependencies:

    dotnet restore
  3. Apply migrations to create the database:

    dotnet ef database update
  4. Run the application:

    dotnet run

Project Structure

  • Models: Contains the User and Order entity classes.
  • Data: Contains the ApplicationDbContext class for EF Core.
  • Migrations: Contains the EF Core migration files.
  • Program.cs: Configures the services and middleware, and defines the endpoints.

Endpoints

Users

  • GET /users: Retrieve all users.
  • GET /users/{id}: Retrieve a user by ID.
  • POST /users: Create a new user.
  • PUT /users/{id}: Update an existing user.
  • DELETE /users/{id}: Delete a user by ID.

Orders

  • GET /orders: Retrieve all orders.
  • GET /orders/{id}: Retrieve an order by ID.
  • POST /orders: Create a new order.
  • PUT /orders/{id}: Update an existing order.
  • DELETE /orders/{id}: Delete an order by ID.

Using Swagger

Once the application is running, you can use Swagger to explore and test the API endpoints. Swagger will be available at:

Database Management

The application uses SQLite for the database. The connection string is configured in Program.cs:

builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
    options.UseSqlite($"Data Source={AppDomain.CurrentDomain.BaseDirectory}app.db");
});

minimalapi.net8's People

Contributors

mathewbeats avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.