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.
Objectives
Use an ORM to query against a database
Requirements
Explorer Mode
[x] Create a database called SafariVacation / safari_vacation
[x] This will have 1 table called SeenAnimals / seen_animals that has the following columns
dotnet ef dbcontext scaffold "server=localhost;database=<<DatabaseName>>" Npgsql.EntityFrameworkCore.PostgreSQL -c <<DatabaseName>>Context
- 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.
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.
Objectives
Requirements
Explorer Mode
SafariVacation
/safari_vacation
SeenAnimals
/seen_animals
that has the following columnsId
/id
(int)Species
/species
(string)CountOfTimesSeen
/count_of_times_seen
(int)LocationOfLastSeen
/location_of_last_seen
(string)pgcli
.CountOfTimesSeen
andLocationOfLastSeen
for an animalJungle
Desert
.CountOfTimesSeen
and get a total number of animals seenCountOfTimesSeen
oflions
,tigers
andbears
Adventure Mode
LastSeenTime
, with a type of DateTime. This will require a new migration to added and ran.Epic Mode
Additional Resources
.NET
Here are the interesting commands you will need for tonights assignment
To add Entity Framework to your project:
To create your database:
To create the DbContext
dotnet ef migrations add AddBaordGameTable
dotnet ef database update