0
我有映射关系 一个问题,而在Visual Studio逆向工程.NET无效的列名,而使用继承
我使用继承:
public class Quiz : Component
{
public QuizQuestion rootQuestion { get; set; }
public override String getType() { return "quiz"; }
}
财产rootQuestion
未在规定母类,它只存在于子类
Quiz
在我的sqlserver数据库中不存在表(数据库中只存在QuizQuestions
和Component
表e,(我的老师告诉我这样做这个项目的java部分 )。
但我想子类测验有一个属性rootQuestion
,指的是我的数据库中的quizRootQuestion
。因此,这里是我所做的:
public class QuizMapper : EntityTypeConfiguration<Quiz>
{
public QuizMapper()
{
this.HasKey(t => t.ComponentID);
this.HasOptional(c => c.rootQuestion)
.WithMany().Map(m => m.MapKey("quizRootQuestionID"));
}
}
public class QuizQuestionMap : EntityTypeConfiguration<QuizQuestion>
{
public QuizQuestionMap()
{
// Properties
// Table & Column Mappings
this.HasKey(t => t.QuestionID);
this.ToTable("QuizQuestions");
this.Property(t => t.QuestionID).HasColumnName("questionID");
}
}
我得到了,我要在我的浏览器中运行这个错误:
无效的列名称rootQuestion_QuestionID“。
表在我的数据库:
组件:
componentId
quizRootQuestionID
TypeId(=discriminator)
QuizQuestions
questionID
question
有人可以告诉我什么,我做错了什么?
是的,我使用实体框架5. 结构:一个学习的课程有不同的组件,其中1个是 测验 – PrisonMike