using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; namespace DamageAssesment.Api.Questions.Db { public class QuestionDbContext : DbContext { private IConfiguration _Configuration { get; set; } public QuestionDbContext(DbContextOptions options, IConfiguration configuration) : base(options) { _Configuration = configuration; } protected override void OnConfiguring(DbContextOptionsBuilder options) { // connect to sql server with connection string from app settings options.UseSqlServer(_Configuration.GetConnectionString("QuestionConnection")); } public DbSet Questions { get; set; } public DbSet QuestionTypes { get; set; } public DbSet QuestionsTranslations { get; set; } public DbSet QuestionCategories { get; set; } public DbSet CategoryTranslations { get; set; } public QuestionDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); } } }