DamageAssessment_Backend/DamageAssesmentApi/DamageAssesment.Api.Questions/Db/QuestionDbContext.cs
2023-08-25 18:24:46 -04:00

35 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace DamageAssesment.Api.Questions.Db
{
public class QuestionDbContext : DbContext
{
public DbSet<Db.Question> Questions { get; set; }
public DbSet<Db.QuestionType> QuestionTypes { get; set; }
public DbSet<Db.QuestionsTranslation> QuestionsTranslations { get; set; }
public DbSet<Db.QuestionCategory> QuestionCategories { get; set; }
public QuestionDbContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Question>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<QuestionType>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<QuestionsTranslation>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<QuestionCategory>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
}
}