I have a simple architectural question and would love some advice.
I am trying to get familiar with ASP.NET MVC 3. To do so I am coding a small TV Shows gallery as an exercise.
My Models folder holds several classes, including a TvShow
, a Season
and an Episode
class. Those are naturally tied together: a TvShow
instance has a one-to-many relationship with Season
instances while a Season
instance has a one-to-many relationship with Episode
instances.
Using ASP.NET's Entity Framework, how should I model these one-to-many relationships ? I see 2 options:
- Option 1 - The
TvShow
class has aList<Season> seasons
field - Option 2 - The
Season
class has aTvShow tvShow
field
Option 2 seems more natural to me because it mimics the underlying database design. It is also the choice made by Microsoft in their MvcMusicStore tutorial. However, I'm wondering if there is a reason to reject Option 1 - either for database / EF related matters or for OO-design matters.
Thoughts?