Oregon Trail Mini Project
Let’s build a small application to practice what we’ve learned in Mod2. Read throught the entire spec below before starting!
The Oregon Trail
- Create a Console Application in Visual Studio.
- You can call the project and solution
Caravan
- You can call the project and solution
- Initialize a git repository in your solution.
- Add a remote repository on GitHub
Building our Classes
- Create a branch called
classes
- In your Caravan project, add classes outlined below.
- Make sure to test your classes!
- Commit after each class is complete - you should have 3 commits!
- When all three classes have been built, merge your
classes
branch into yourmain
branch. - Push your main branch to GitHub.
Passenger
A passenger has a Name, an Age, a Destination, and a Wagon
Wagon
A Wagon has a Name (like ‘Old Faithful’), NumWheels, Covered (true/false), and Passengers.
Connecting a Database
- Checkout a new branch called
migrations
- Install the following packages:
- Npgsql.EntityFrameworkCore.PostgreSQL
- Microsoft.EntityFrameworkCore.Tools
- EFCore.NamingConventions
- Add a CaravanContext class
- It will be helpful to review the Intro to ORM lesson for this!
- Add a migration to create your database.
- Run your migration!
- Commit your work, and merge your
migrations
branch into yourmain
branch.
EF Queries
In your program.cs
create a caravan summary that will output the following information:
- Count of passengers in each wagon
- A distinct list of destinations
- The average age of all passengers
- The average age of each wagon’s passengers
- A list of all passengers and the name of the wagon they are riding in