Skip to content

Commit

Permalink
updated exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
uerbzr committed Oct 6, 2023
1 parent ec5e1b6 commit e12c120
Show file tree
Hide file tree
Showing 29 changed files with 409 additions and 709 deletions.
129 changes: 125 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand Down Expand Up @@ -29,7 +29,6 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/

Expand Down Expand Up @@ -58,11 +57,14 @@ dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/

# .NET Core
# .NET
project.lock.json
project.fragment.lock.json
artifacts/

# Tye
.tye/

# ASP.NET Scaffolding
ScaffoldingReadMe.txt

Expand Down Expand Up @@ -91,6 +93,7 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
Expand Down Expand Up @@ -294,6 +297,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -350,6 +364,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand All @@ -360,4 +377,108 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

# JetBrains Rider
*.sln.iml

##
## Visual studio for Mac
##


# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/

# Mac bundle stuff
*.dmg
*.app

# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

*/**/bin/Debug
*/**/bin/Release
*/**/obj/Debug
*/**/obj/Release
/exercise.pizzashopapi/appsettings.json
/exercise.pizzashopapi/appsettings.Development.json
56 changes: 16 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
# Database Migrations Exercise
# C# Migrations Exercise

## Learning Objectives
- Use Entity Framework migrations to manage changes to table structures
## Pizza Shop Api

Pizza Shop needs a very simple ordering system with just just 3 tables:

## Instructions
-Customer
-Pizza
-Order

1. Fork this repository
2. Clone your fork to your machine
3. Open the project in Visual Studio
4. I have restricted config from being uploaded to github (see the end of .gitignore)
What you need to do now is change the PizzaContext.cs file to use your ElephantSql instance.
If you Ctrl+c then Ctrol+v on the App.config.fake file to create a duplicate of this. Remove the extension
.fake so the file name is App.config Now you can look at the connection string and replace each item with your own Elephant credentials.
```
-Add an appsettings.json file and connect to your database.
-Run a migration to create the Customer / Pizza tables
-Add an address to the Customer object then run another migration
-Complete the Order model with an Id, OrderDate and a foreign key to the Customer and Pizza (and include a Pizza/Customer property). A single order only has 1 customer ordering 1 pizza.
-Run another migration to add the latest updates to the database
-Seed some data for the orders... Dave likes a Cheese & Pineapple pizza and Nigel likes Vegan ones.
-Complete the only method in the Repository to GetOrders() being sure to include the customer and pizza in the results.
```

5. In the Package Manager Console initiate the migraion: PM> Add-Migration InitialCreate

Build started...
Build succeeded.
To undo this action, use Remove-Migration.

This should generate a Migrations folder with some c# to create the database.


6. In the Package Manager Console update the database : PM> Update-Database

Build started...
Build succeeded.
Applying migration '20230424151917_InitialCreate'.
something like this should appear!


7. Now make a change.



## FYI

If you are using VSCode you can install EF using: $ dotnet tool install -g dotnet-ef

and run commands like this: $ dotnet ef migrations add InitialCreate
$ dotnet ef database update

from your console.
Try and complete this exercise with at least 3 migrations
Loading

0 comments on commit e12c120

Please sign in to comment.