An inventory management
project with angular and .net core apis.
- I have built this project in early 2024 with
.net 8
andangular 17
. I had created two separate github repositories forfront-end
andbackend
. Now, I have moved them to a single repository. - I have upgraded it to
.NET 9
andAngular 20
. - I have used
sql server 2022
as a database. I have usedstored procedures
in all the places. I have taken a challange and migrated it toPostgreSQL
to see how comfortable am I with Postgres without entity framework and what challanges we face during migrations. It was not easy but fun ride. - I also have added feautres like
suppliers
andauthentication
. - I have added
entity framework core
for future updates and specially for migrations. I use two machines back and forth and it was hard to maintain both dev databases. Entity framework migrations helped me with that. Howeverm I haven't used it anywhere yet. May be I will use it authentication feature (yeah, I am working on this feature).
- Backend: Asp.net core web api (9.0) (upgrade from .net 8)
- Database: Postgres (previously sql server 2022)
- ORM: Dapper(Most of the places), EF Core
- Frontend: Angular 20 (upgraded from v18)
- UI: Angular material (UI component library)
- State Management:
Ngrx componnent store
(Almost everywhere) andservice with signal
(For newer features).
- Make sure you have installed
dotnet 9.0
sdk, a latest version node js and angular cli. - Clone this project: Open a terminal and run
git clone https://github.com/rd003/InventroyMgt.git
cd
- With command
code .
, your project will be opened in VS Code. - You need to run both projects separately:
- Open
appsettings.json
and configure the connection string according to your database. - Open
InventoryMgt.Api
in the integrated terminal. - Execute the command
dotnet run
, to run this project. It will automatically generate the database and seed some data
- Open the another integrated terminal (keep the terminal open, where your backend project is running).
- Execute the command
npm i
to install all the dependencies. - Execute
ng serve --open
to run and open this project in browser. - A login screen will popup and you need to enter these credentials:
Username: admin
password: Admin@123
You might get error while executing them using dot net CLI
, because we have multiple projects. You won't face this problem while using Package Manage Console
of Visual Studio
.
Error might be something like this:
Unable to create a 'DbContext' of type 'RuntimeType'. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[InventoryMgt.Data.models.AppDbContext]' while attempting to activate 'InventoryMgt.Data.models.AppDbContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Visit to the root directory of backend project, which named backend
in our case. So visit to backend
directory and execute these commands in a sequece:
Creating migration:
dotnet ef migrations add SomeMigration --project InventoryMgt.Data --startup-project InventoryMgt.Api
Note: You need to replace SomeMigration
to a meaningful name.
Update database: However, this project can apply migration while you run it. But, in case you manually want to run it.
dotnet ef database update --project InventoryMgt.Data --startup-project InventoryMgt.Api
A Github ⭐ is appreciated 🙂.