我在这些电话上收到了这些错误。我一定做错了什么:-)但是在哪里?
在我的控制器上我有这个:
var faqs = _context.Faqs.Include(c=>c.Categories).ThenInclude(c=>c.category);
var forums = _context.Forums.Include(c => c.Categories).ThenInclude(c => c.category);
错误:
Additional information: Invalid column name 'FaqId'.
Additional information: Invalid column name 'ForumId'.
代码:
public class Category
{
[Key]
public string Id { get; set; } = Guid.NewGuid().ToString();
[Required()]
public string Name { get; set; }
[Required()]
public Int64 ApplyTo { get; set; }=0;
[Required()]
public Int64 EnumNumber { get; set; } = 0;
}
public class CategoryObject
{
[Key]
public string Id { get; set; } = Guid.NewGuid().ToString();
/// <summary>
/// Refers to class object like FAQs, Forum
/// </summary>
public string ObjectId { get; set; }
public virtual Category category { get; set; }
public string CategoryId { get; set; }
}
public class Faq
{
[Key]
public string Id { get; set; } = Guid.NewGuid().ToString();
[Required()]
public string Name { get; set; }
[Required()]
public string Answer { get; set; }
/// <summary>
/// List of all categories this FAQ belongs
/// </summary>
public virtual ICollection<CategoryObject> Categories { get; set; }
}
public class Forum
{
[Key]
public string Id { get; set; } = Guid.NewGuid().ToString();
[Required()]
public override string Name { get; set; }
public string Description { get; set; } = "";
/// <summary>
/// List of all categories this Forum belongs
/// </summary>
public virtual ICollection<CategoryObject> Categories { get; set; }
}
所有想法都是我有一个标有某些类别的对象,并希望拉出该对象具有的所有类别。在这种情况下,FAQ和论坛以及其他人可以进行一些分类。可能有更好的方法?也欢迎提出建议。
由于