using Microsoft.EntityFrameworkCore; namespace DamageAssesment.Api.Locations.Db { public class LocationDbContext : DbContext { private IConfiguration _Configuration { get; set; } public LocationDbContext(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("LocationConnection")); } public DbSet Locations { get; set; } public DbSet Regions { get; set; } public LocationDbContext(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(); } } }