We are taking a surprise trip to the Savannah for a safari to see all sorts of exotic animals. During our time their we want to keep track of all the animals we have seen. For this, we need to create a database, as well as a small console application to help record what we see.
- Use an ORM to query against a database
Create a database called
This will have 1 table called
seen_animalsthat has the following columns
- NOTE: This should be made all in the code (C#/Ruby), and not created in the
Create a small console application, and create the following queries using your languages ORM.
- Display all animals the user has seen
- Update the
LocationOfLastSeenfor an animal
- Display all animals seen in the
- Remove all animals that I have seen in the
- Add all the
CountOfTimesSeenand get a total number of animals seen
- Get the
- Add a new column called
LastSeenTime, with a type of DateTime. This will require a new migration to added and ran.
- Continue to make progress on your capstone project.
Here are the interesting commands you will need for tonights assignment
To add Entity Framework to your project:
dotnet add package Microsoft.EntityFrameworkCore.Design --version 2.1.3
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version 2.1.2
- To create your database:
- To create the DbContext
dotnet ef dbcontext scaffold "server=localhost;database=<
- Add a migration:
dotnet ef migrations add AddBaordGameTable
- Update your database
dotnet ef database update
- Documentation: [Dotnet EF CLI Docs](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet) ## Reading Material To prepare for upcoming lessons, students might want to read links shared here.