DamageAssessment_Backend/DamageAssesmentApi/DamageAssesment.Api.Responses/Db/SurveyResponseDbContext.cs

28 lines
1003 B
C#
Raw Normal View History

2023-08-15 22:52:30 -05:00
using Microsoft.EntityFrameworkCore;
2023-10-04 17:45:51 -05:00
namespace DamageAssesment.Api.Responses.Db
2023-08-15 22:52:30 -05:00
{
public class SurveyResponseDbContext:DbContext
{
2023-08-18 16:14:41 -05:00
private IConfiguration _Configuration { get; set; }
public SurveyResponseDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
2023-08-15 22:52:30 -05:00
{
2023-08-18 16:14:41 -05:00
_Configuration = configuration;
2023-08-15 22:52:30 -05:00
}
2023-08-18 16:14:41 -05:00
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
// connect to sql server with connection string from app settings
2023-10-10 15:28:30 -05:00
options.UseSqlServer(_Configuration.GetConnectionString("ResponsesConnection"));
2023-08-18 16:14:41 -05:00
}
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SurveyResponse>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
2023-08-15 22:52:30 -05:00
}
}