using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; namespace DamageAssesment.Api.UsersAccess.Db { public class UsersAccessDbContext : DbContext { public DbSet Users { get; set; } public DbSet Roles { get; set; } public DbSet Tokens { get; set; } private IConfiguration _Configuration { get; set; } public UsersAccessDbContext(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("UsersAccessConnection")); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); modelBuilder.Entity() .Property(item => item.Id) .ValueGeneratedOnAdd(); } } }