Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Entity Framework Basics Extending Our Entity Data Model Using a One-to-Many Relationship

Why don't we need to add dbset property for Series in the context class?

How the entity framework create a table for Series when we don't add dbset property for it in context class?

There's a question about it before, but I don't understand the answer.

https://teamtreehouse.com/community/why-are-we-not-creating-a-dbset-property-of-type-series-in-the-context-class-entity-framework

1 Answer

Steven Parker
Steven Parker
231,275 Points

Table creation is discussed in the Where's Our Data? video starting at about 4:00.

In short, the DbSet entries are examined for entity relationships, using the models. The models are then used to create the conceptual model, which is then translated into the storage model. The storage model is used to create the actual tables.

The Series entity doesn't have a DbSet, but it has a one-to-many relationship with ComicBook, which causes it to be included in the conceptual model and storage model, and then to be created as a table.