重构试卷相关内容
This commit is contained in:
@@ -22,8 +22,12 @@ namespace TechHelper.Context.Configuration
|
||||
|
||||
// 配置 QuestionId 列 (已修正拼写)
|
||||
builder.Property(aq => aq.QuestionId)
|
||||
.HasColumnName("question_id")
|
||||
.IsRequired();
|
||||
.HasColumnName("question_id");
|
||||
|
||||
|
||||
builder.Property(aq => aq.QuestionGroupId)
|
||||
.HasColumnName("question_group_id");
|
||||
|
||||
|
||||
// 配置 QuestionNumber 列
|
||||
builder.Property(aq => aq.QuestionNumber)
|
||||
@@ -36,7 +40,7 @@ namespace TechHelper.Context.Configuration
|
||||
.IsRequired(); // 通常创建时间字段是非空的
|
||||
|
||||
builder.Property(aq => aq.Score)
|
||||
.HasColumnName("score");
|
||||
.HasColumnName("score");
|
||||
|
||||
// 配置 AssignmentGroupId 列
|
||||
// 该列在数据库中名为 "detail_id"
|
||||
@@ -44,7 +48,11 @@ namespace TechHelper.Context.Configuration
|
||||
.HasColumnName("group_id")
|
||||
.IsRequired();
|
||||
|
||||
// 配置 IsDeleted 列
|
||||
|
||||
builder.Property(aq => aq.IsGroup)
|
||||
.HasColumnName("is_group") // 修正为一致的列名
|
||||
.IsRequired(); // IsGroup 应该是必需的
|
||||
// 配置 IsDeleted 列
|
||||
builder.Property(aq => aq.IsDeleted)
|
||||
.HasColumnName("deleted")
|
||||
.HasDefaultValue(false); // 适用于软删除策略
|
||||
@@ -61,6 +69,12 @@ namespace TechHelper.Context.Configuration
|
||||
.HasForeignKey(aq => aq.QuestionId) // 外键是 AssignmentQuestion.QuestionId
|
||||
.OnDelete(DeleteBehavior.Cascade); // 当 Question 被删除时,相关的 AssignmentQuestion 也级联删除。
|
||||
|
||||
builder.HasOne(aq => aq.QuestionGroup)
|
||||
.WithMany(qg => qg.AssignmentQuestions)
|
||||
.HasForeignKey(aq => aq.QuestionGroupId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
|
||||
// ---
|
||||
// 配置 AssignmentQuestion 到 AssignmentGroup 的关系 (多对一)
|
||||
// 一个 AssignmentQuestion 属于一个 AssignmentGroup。
|
||||
|
Reference in New Issue
Block a user