I have been attempting to create a mini project in asp.NET MVC4 that simulates a small gaming review website. There's nothing spectacular going on I just wanted to get a handle on different aspects of the tools and language.
Currently I was thinking of creating a database set to associate Genres to an ID so when I create a Game database set I can reference the games by related genres. I was using a Code first approach to create the models, but I'm not sure how to properly reference the genres that are stored within a virtual collection so that If I create a table based on Genre or a table based on Game that they will reference properly. I'm just learning this MVC approach so I apologize if my terminology is off.
public class GamingModels : DbContext
{
public DbSet<Games> GameDb { get; set; }
public DbSet<Genre> GenreDb { get; set; }
public GamingModels()
: base("DefaultConnection")
{ }
public class Games {
public int ID { get; set; }
public string Title { get; set; }
public string Summary { get; set;}
public int Rating { get; set; }
public virtual ICollection<Genres> Genres { get; set; }
}
public class Genre {
public int ID { get; set; }
public string Name { get; set; }
public virtual ICollection<Games> Games { get; set; }
}
}