So, I am working on a project dealing with a game. I have three projects right now, Web, Data, Data.EF. I would like the Web to not know anything about the concrete classes in Data.EF, but instead only reference the Interfaces in Data. The problem I am running into is that I have two classes Dungeon and AvailableDay. AvailableDay has two important members. Weekday which is a DayOfWeek
and IEnumerable<IDungeon> Dungeons
which is a "list" of dungeons that are available that day. The issue I am having is that I keep getting this error:
The navigation property 'Dungeons' is not a declared property on type 'AvailableDay'. Verify that it has not been explicitly excluded from the model and that it is a valid navigation property.
My AvailableDay mapping class is:
internal class AvailableDayMapping : EntityTypeConfiguration<AvailableDay>
{
public AvailableDayMapping()
{
this.ToTable("AvailableDays", "dbo");
this.HasKey(t => t.ID);
this.HasKey(t => t.DungeonID);
this.HasRequired(t => t.Dungeons).WithMany().HasForeignKey(t => t.DungeonID);
this.Property(t => t.Weekday);
}
}
AvailableDay class:
public class AvailableDay : IAvailableDay
{
public int ID { get; set; }
public int DungeonID { get; set; }
public virtual IEnumerable<IDungeon> Dungeons { get; set; }
public DayOfWeek Weekday { get; set; }
}
I am trying to query it by:
public async Task<IEnumerable<IAvailableDay>> GetAvailableDaysAsync()
{
return await _Context.AvailableDays
.Include(t => t.Dungeons)
.GroupBy(t => t.Weekday).SelectMany(t => t).ToListAsync();
}
How can I pull in a list of Dungeon data while only allowing the Web to access it through interfaces?