Many to Many with ORM Lab

Lab Objectives

  • Practice building a many-to-many relationship with an ORM
  • Practice inserting records that are part of a many-to-many relationships

In today’s lab, we’re going to add to our library application and database. Before beginning make sure you have the library application open.

Today you are going to build two many-to-many relationships. The first will be the relationship between books and authors that you created using SQL statements earlier in the Mod. The second many-to-many relationship will be of your choosing!

(5 minutes) With your partner: Brainstorm potential many-to-many relationships we could add to our library database. These relationships can utilize entirely new tables or use tables that already exist in your database. Before we come back together, post your ideas on the slack thread. We will discuss these ideas as a group when we come back together.

Part 1

Add a many-to-many relationship between books and authors, this time using Entity Framework to create that relationship for us.
Once the database tables look as you expect, write insert statements to add some records.

Part 2

Build one of the many-to-many relationships brainstormed earlier.
Once the database tables look as you expect, write insert statements to add some records.

🌶️Part 3

Hardcoding values is a great place to start, but it would be even better if we could take user input and then use that to insert records into our database. Try to figure out how you could take user input and use that in one of the inserts you created during Part 1 or Part 2.

Lesson Search Results

Showing top 10 results