DamageAssessment_Backend/DamageAssesmentApi/DamageAssesment.Api.Responses/Db/SurveyResponseDbContext.cs
2023-10-10 16:28:30 -04:00

28 lines
1003 B
C#

using Microsoft.EntityFrameworkCore;
namespace DamageAssesment.Api.Responses.Db
{
public class SurveyResponseDbContext:DbContext
{
private IConfiguration _Configuration { get; set; }
public SurveyResponseDbContext(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("ResponsesConnection"));
}
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SurveyResponse>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
}
}