Exercise Tracker


So far we have been developing our applications without thinking too much about their design. In software development, we’ll often use “general repeatable solutions to commonly occurring problems”, the so called design patterns.

We will build an exercise tracker using the “Repository Pattern”, an almost universally used solution for data persistence. It creates a layer between business logic and data access, which helps us create more loosely-coupled, testable and maintainable applications. You’ll be dealing with repositories on a daily-basis when you get your C# job!


  • This is an application where you should record exercise data.
  • You should choose one type of exercise only. We want to keep the app simple so you focus on the subject you're learning and not on the business complexities.
  • You can choose raw SQL or Entity Framework for your data-persistence.
  • The model for your exercise class should have at least the following properties: {Id INT, DateStart DateTime, DateEnd DateTime, Duration TimeSpan, Comments string}
  • Your application should have the following classes: UserInput, ExerciseController, ExerciseService (where business logic will be handled) and ExerciseRepository. These classes might feel empty at first but they'll be needed in most applications as they grow.
  • You can choose between SQLite or SQLServer.
  • You need to use dependency injection to access the repository from the controller.


Here are a few resources that might be helpful.

There are many other Youtube videos and blog articles about the Repository Pattern. Google and ChatGPT are your best friends!


  • Don't forget to add validation to your app.
  • Don't forget to create a Github repository for your project from the beginning.
  • You might come across the concept of Unit of Work in some tutorials. I suggest you don't use it, so you focus on learning how a single repository works.
  • Keep your application simple (only one table). Complexity is your enemy at the moment, since you want to focus solely on learning the pattern.


  • To illustrate the separation provided by the repository pattern, create a different branch of your project where you'll replace Entity Framework by Dapper or ADO.NET in your repository. You'll notice that you won't need to touch your controller.
  • Create an application with two types of exercises (ex. weights and cardio), using EF for one and Raw SQL for the other
Log in to mark this article as read and save your progress.
An unhandled error has occurred. Reload 🗙