29 lines
No EOL
942 B
C#
29 lines
No EOL
942 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using SurveyLib.Core.Models;
|
|
using SurveyLib.Core.Models.QuestionVariants;
|
|
|
|
namespace SurveyLib.Infrastructure.EFCore.Data;
|
|
|
|
public class SurveyDbContext : DbContext
|
|
{
|
|
public DbSet<Survey> Surveys { get; set; }
|
|
|
|
public DbSet<QuestionBase> Questions { get; set; }
|
|
public DbSet<SingleAnswerQuestion> SingleAnswerQuestions { get; set; }
|
|
public DbSet<MultipleAnswerQuestion> MultipleAnswerQuestions { get; set; }
|
|
public DbSet<TextQuestion> TextQuestions { get; set; }
|
|
|
|
public DbSet<AnswerVariant> AnswerVariants { get; set; }
|
|
|
|
public DbSet<Completion> Completions { get; set; }
|
|
public DbSet<Answer> Answers { get; set; }
|
|
|
|
public SurveyDbContext(DbContextOptions options) : base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Answer>().HasKey(a => new { a.CompletionId, a.QuestionId });
|
|
}
|
|
} |