//
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using backend.Data;
#nullable disable
namespace backend.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260603125735_InitialCreate")]
partial class InitialCreate
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("Points")
.HasColumnType("int");
b.Property("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.HasKey("Id");
b.ToTable("KhatmItems");
b.HasData(
new
{
Id = 1,
Points = 5,
Title = "ختم نادعلی"
},
new
{
Id = 2,
Points = 10,
Title = "خطبه غدیر"
},
new
{
Id = 3,
Points = 7,
Title = "دعای توسل"
});
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("CorrectOption")
.HasColumnType("int");
b.Property("Option1")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("Option2")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("Option3")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("Option4")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("QuestionText")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.HasKey("Id");
b.ToTable("QuizQuestions");
b.HasData(
new
{
Id = 1,
CorrectOption = 1,
Option1 = "سال ۱۰ هجری",
Option2 = "سال ۱۱ هجری",
Option3 = "سال ۹ هجری",
Option4 = "سال ۱۲ هجری",
QuestionText = "غدیر در چه سالی واقع شد؟"
},
new
{
Id = 2,
CorrectOption = 3,
Option1 = "ابوبکر",
Option2 = "عمر",
Option3 = "علی (ع)",
Option4 = "عثمان",
QuestionText = "پیامبر اکرم (ص) در غدیر چه کسی را به عنوان جانشین معرفی کردند؟"
},
new
{
Id = 3,
CorrectOption = 2,
Option1 = "مسجد النبی",
Option2 = "غدیر خم",
Option3 = "مکه",
Option4 = "مدینه",
QuestionText = "خطبه غدیر در کجا ایراد شد؟"
});
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("Contact")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("TrackingCode")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("nvarchar(8)");
b.HasKey("Id");
b.HasIndex("Contact")
.IsUnique();
b.HasIndex("TrackingCode")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("IsSelected")
.HasColumnType("bit");
b.Property("KhatmItemId")
.HasColumnType("int");
b.Property("LastModified")
.HasColumnType("datetime2");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("KhatmItemId");
b.HasIndex("UserId", "KhatmItemId")
.IsUnique();
b.ToTable("UserKhatmSelections");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("IsCorrect")
.HasColumnType("bit");
b.Property("QuestionId")
.HasColumnType("int");
b.Property("SelectedOption")
.HasColumnType("int");
b.Property("UserQuizAttemptId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("UserQuizAttemptId");
b.ToTable("UserQuizAnswers");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("CompletedAt")
.HasColumnType("datetime2");
b.Property("CorrectAnswersCount")
.HasColumnType("int");
b.Property("ParticipationPoints")
.HasColumnType("int");
b.Property("TotalQuizPoints")
.HasColumnType("int");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserQuizAttempts");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("TotalPoints")
.HasColumnType("int");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("UserTotalScores");
});
modelBuilder.Entity("backend.Models.UserKhatmSelection", b =>
{
b.HasOne("backend.Models.KhatmItem", "KhatmItem")
.WithMany("UserSelections")
.HasForeignKey("KhatmItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.User", "User")
.WithMany("KhatmSelections")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("KhatmItem");
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserQuizAnswer", b =>
{
b.HasOne("backend.Models.QuizQuestion", "Question")
.WithMany("Answers")
.HasForeignKey("QuestionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("backend.Models.UserQuizAttempt", "QuizAttempt")
.WithMany("Answers")
.HasForeignKey("UserQuizAttemptId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Question");
b.Navigation("QuizAttempt");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("QuizAttempt")
.HasForeignKey("backend.Models.UserQuizAttempt", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.UserTotalScore", b =>
{
b.HasOne("backend.Models.User", "User")
.WithOne("TotalScore")
.HasForeignKey("backend.Models.UserTotalScore", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("backend.Models.KhatmItem", b =>
{
b.Navigation("UserSelections");
});
modelBuilder.Entity("backend.Models.QuizQuestion", b =>
{
b.Navigation("Answers");
});
modelBuilder.Entity("backend.Models.User", b =>
{
b.Navigation("KhatmSelections");
b.Navigation("QuizAttempt");
b.Navigation("TotalScore");
});
modelBuilder.Entity("backend.Models.UserQuizAttempt", b =>
{
b.Navigation("Answers");
});
#pragma warning restore 612, 618
}
}
}