-
Notifications
You must be signed in to change notification settings - Fork 16
Adding Something New
zysim edited this page May 24, 2022
·
10 revisions
This describes the steps you need for adding (and editing) classes in the main project (LeaderboardBackend
).
Always remember to run dotnet format style
and dotnet format whitespace
in solution root before pushing commits. Alternatively, refer to our style guide.
From here on, we assume you're in the main project.
- Add a page for tests
- Create the model in
Models/Entities/
- Add a DbSet of the model in
Models/Entities/ApplicationContext.cs
- Add any default values, if needed, in
OnModelCreating
- Add any default values, if needed, in
- Create a new migration with the
ef
CLI tool:dotnet ef migrations add -c ApplicationContext Create<ModelName>
- This creates a file in
Migrations
- You can migrate locally with
dotnet ef database update -c ApplicationContext
- This creates a file in
- Make your changes
- Create a new migration:
dotnet ef migrations add -c ApplicationContext <ModelName>_<ChangeSummary>
- Create the controller in
Controllers/
- Create an interface for the service in
Services/
- Create its implementation in
Services/Impl/
- Add the service to
Program.cs
:// Program.cs // ... builder.Services.AddScoped<IJudgementService, JudgementService>(); builder.Services.AddScoped<IRunService, RunService>(); builder.Services.AddScoped<INewService, NewService>(); // The new service
This allows controllers to call services via dependency injection in the their constructors.
Thanks for considering contributing to LB.GG 😌