Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

University assignment: introduction to C# and Entity Framework.

License

Notifications You must be signed in to change notification settings

adniec/EntityFrameworkExercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exercises

1. One-to-Many relationship

  • Schema:
    • Schema
  • To do:
    • create relationship from schema
    • from user input add new product
    • create supplier and link it to newly added product
  • Reference:
  • Solution:

2. Many-to-One relationship

  • Schema:
    • Schema
  • To do:
    • change relationship from exercise 1 to Many-to-One
    • add few products and link them to supplier
  • Reference:
  • Solution:

3. Both ways relationship

  • Schema:
    • Schema
  • To do:
    • merge relationships from exercise 1 and 2
    • show how to link supplier to products in each way
  • Reference:
  • Solution:

4. Many-to-Many relationship

  • Schema:
    • Schema
  • To do:
    • create relationship from schema
    • list all products from one invoice
    • show invoices containing chosen product
  • Reference:
  • Solution:

5. Inheritance: Table per Hierarchy (TPH)

  • Schema:
    • Schema
  • To do:
    • create relationship from schema using TPH strategy
    • fill tables with example data
    • use three different types of query to access your data
  • Reference:
  • Solution:

6. Inheritance: Table per Type (TPT)

  • To do:
    • modify inheritance strategy from exercise 5 to TPT
  • Reference
  • Solution:

Setup

  • Visual Studio
  • Create project
    • To create new project follow guide.
  • Open project
    • Clone repository and switch to branch with solution number.
    • Open Visual Studio and select from menu:
      • File -> Open -> Project/Solution
      • Pick App.sln from App directory of solution

Run

Open project in Visual Studio and press run button located on the top bar:

run

  • Results:
    • Terminal with results will show up.
    • Modified database will be available in project location under path:
  • Exception:
    • If Microsoft.EntityFrameworkCore.DbUpdateException raises go to:
    • Solution Explorer -> Right click on database -> Properites -> Copy to Output Directory
    • Set it to:
      • Copy if newer if you want update database in each run of program
      • Copy always if you want to clean database before each run of program
  • Troubleshooting:

Project Information

Author

Adrian Niec

License

This project is under the MIT License

Releases

No releases published

Packages

No packages published

Languages