Skip to content

Repository files navigation

⚡ Energy Service API

A sample .NET 9 Web API for managing customers, products, tariffs, and orders for energy-based services (electricity, gas, etc.).


🧩 Overview

This project demonstrates a typical business structure for energy contract management:

Customer
 └── Order
      └── OrderDetail
           ├── Product
           └── Tariff → Unit

Each tariff can have multiple time-based prices.


🧠 Tech Stack

  • .NET 9 / ASP.NET Core Web API
  • Entity Framework Core
  • SQL Server (default)
  • Swagger / OpenAPI enabled by default

🗂️ Project Structure

Folder Description
Models/ Entity classes (Customer, Product, Tariff, Unit, Order, OrderItem)
Data/ AppDbContext and SeedData for initialization
Controllers/ API endpoints (to be extended)
Migrations/ EF Core migrations

⚙️ Configuration

Edit your appsettings.json to set the connection string:

"ConnectionStrings": {
  "DefaultConnection": "xxx"
}

🌱 Seeding Data

On first startup, the app automatically seeds demo data.

To reseed the database (for development only), use:

SeedData.Initialize(db, force: true);

This clears all tables and re-inserts demo data.


🧱 Migrations

Generate a new migration whenever you modify the model classes:

dotnet ef migrations add AddNewFieldName
dotnet ef database update

👤 Author

Created by Mahi © 2025

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages