I want to get data from multiple tables based on the itemId of each table.
Currently I have an item table with an ItemId column that has a 1:m relationship with another tables called ExplicitMods:
namespace Poe.Models
{
public class Item
{
[Key]
public string ItemId { get; set; }
public List<ExplicitMod> ExplicitMods { get; set; }
}
}
namespace Poe.Models
{
public class ExplicitMod
{
public ExplicitMod(string Name)
{
this.Name = Name;
}
[Key]
public string ItemId { get; set; }
public string Name { get; set; }
}
}
I also have a context with both tables set up:
namespace Poe.DataAccess
{
public class DatabaseContext : DbContext
{
public DbSet<Item> Items { get; set; }
public DbSet<ExplicitMod> ExplicitMod { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
}
}
}
I then try to call the item tables, search on a random name called "Brood Star", and join the explicitMod table:
public static void Search()
{
//return FindItems(i);
using (var db = new DatabaseContext())
{
var blogs = db.Items
.Where(b => b.Name.Equals("Brood Star"))
.Include(es => es.ExplicitMods).ToList();
Debug.Write(blogs);
}
}
What should I do to get the result as one table?
I also get this error:
System.Data.SqlClient.SqlException: 'Invalid object name 'ExplicitMod'