开发者

Why foreign key is added to my table

I have a model:

public class QuestionRevision
{
        [Key]
        public int Id { get; set; }

        public int IdEditor { get; set; }

        public List<Tag> Tags { get; set; }
}

public class Tag
{
        [Key]
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
}

The problem is, I have additional column in Tags table, called QuestionRe开发者_JS百科vision_Id.

Of course one tag could be assigned to many questions, so it's not what I need.

What annotation I need to add to get the desired result?


I've added at Tag class:

public virtual List<QuestionRevision> QuestionRevisions { get; set; }

and at QuestionRevision:

public virtual List<Tag> Tags { get; set; }

and now I have table TagQuestionRevisions, so now it's work how I want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜