32 lines
1.3 KiB
C#
32 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
|
|
{
|
|
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<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; }
|
|
//protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
//{
|
|
// modelBuilder.Entity<Question>()
|
|
// .HasOne(a => a.QuestionType)
|
|
// .WithOne(b => b.Question)
|
|
// .HasForeignKey<QuestionType>(b => b.QuestionTypeID);
|
|
//}
|
|
}
|
|
}
|