I have created a Entity named MediaItem which is Abstract and Game inherits form it. I create the database automatically and I get a table MediaItems and MediaItems_Game.
The issue is when I do the following in my ASP.Net Controller:
private Models.DBContainer dataModel = new DBContainer();
dataModel. ---> Intellisense shows me MediaItem but I can find no way to either navigate to or use MediaItems_Game, how can I solve this? i.e. How can I grab a list of 'Games' with some 'WHERE' constraints on a开发者_StackOverflow中文版nother table (not pictured).
Any info is appreciated, thanks.
This is how inheritance in EF works. You have only single set of parent type. If you want to get just games you will use OfType
method:
var games = dataModel.MediaItems.OfType<Game>().ToList();
精彩评论