Visual Studio .net でのリバース エンジニアリング中にリレーションシップのマッピングに問題があります
私は継承を使用します:
public class Quiz : Component
{
public QuizQuestion rootQuestion { get; set; }
public override String getType() { return "quiz"; }
}
プロパティ「rootQuestion」はマザークラスで指定されておらず、サブクラスにのみ存在します
'Quiz' は、私の sqlserver データベースにテーブルとして存在しません (データベースには QuizQuestions と Component テーブルのみが存在します (私の先生は、このプロジェクトの Java 部分のためにこのようにするように言いました))。しかし、私はサブクラスが欲しいです私のデータベースで quizRootQuestion を参照するプロパティ rootQuestion を持つためのクイズなので、ここで私がしたことは次のとおりです。
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");
}
}
ブラウザで実行しようとすると、次のエラーが表示されます:
Invalid column name 'rootQuestion_QuestionID'.
データベース内のテーブル:
コンポーネント:
componentId
quizRootQuestionID
TypeId(=識別子)
と
QuizQuestions
questionID
question
誰かが私が間違っていることを教えてもらえますか?