using Microsoft.EntityFrameworkCore; namespace DamageAssesment.Api.Surveys.Db { public class SurveysDbContext : DbContext { private IConfiguration _Configuration { get; set; } public SurveysDbContext(DbContextOptions options, IConfiguration configuration) : base(options) { _Configuration = configuration; } public DbSet Surveys { get; set; } public DbSet SurveysTranslation { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) { // connect to sql server with connection string from app settings options.UseSqlServer(_Configuration.GetConnectionString("SurveyConnection")); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); } } }