0

これらの呼び出しでこれらのエラーが発生しました。私は何か間違ったことをしているに違いありません:-)しかし、どこで?

私のコントローラーにはこれがあります:

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 とフォーラムに加えて、その他のカテゴリに分類できます。より良い方法があるかもしれませんか?提案も受け付けています。

ありがとう

4

0 に答える 0