git clone https://github.com/MishaOpstal/LeafBid.git
cd LeafBidcd LeafBidAPIOpen the solution in Visual Studio or JetBrains Rider and wait for dependencies to restore.
Run the following command to start the required services (SQL Server, etc.):
docker compose up --build -dNote: If Docker requests storage permissions, accept them. If the initial run fails after granting permissions, simply run the command again.
Run the following command to install dotnet-ef for use in the next steps:
dotnet tool install --global dotnet-ef --version 8.0.22Run the Entity Framework migrations to set up the database schema:
dotnet ef database updateRestart the services to apply all changes:
docker compose restartThe API should now be running at: http://localhost:5001/swagger
During development, ensure ASPNETCORE_ENVIRONMENT is set to Development. This is configured in docker-compose.yml:
environment:
- ASPNETCORE_ENVIRONMENT=Development- Development: Uses connection string from
appsettings.Development.json - Production: Connection strings are injected via Docker environment variables
⚠️ TODO: Remove theDefaultConnectionfromappsettings.jsonbefore production deployment. Production connection strings should only be passed through Docker environment variables.
The docker-compose.yml file includes:
- SQL Server (exposed on port 1430)
- LeafBid API (exposed on port 5001)
Services communicate internally via Docker networking. The API references SQL Server by service name, not localhost.
Run the following command to seed using an available seeder:
dotnet run --seed <FirstSeederName> <SecondSeederName> ...Example to seed the entire database with dummy data:
dotnet run --seed CompanySeeder UserSeeder ProductSeeder RegisteredProductSeeder AuctionSeeder
If ports 5001 or 1430 are already in use, modify the port mappings in docker-compose.yml.
Ensure Docker services are running and the connection string in appsettings.Development.json uses the SQL Server service name from docker-compose (e.g., Server=sqlserver,1433).
If you see database errors, verify migrations were applied successfully:
dotnet ef migrations list
dotnet ef database updateThis is normal as we do not have live-reloading yet.
In order to apply changes made to the codebase, (re)run docker compose up --build -d
# Create a new migration when you've changed a model
- dotnet ef migrations add <MigrationName>
- dotnet ef database update- Create a feature branch from
main - Make your changes
- Test locally using the development environment
- Submit a pull request
We use the dotnet-ef-seeder from djoufson for seeding the database.
- See it's License here: dotnet-ef-seeder MIT