DamageAssessment_Backend/DamageAssesmentApi/DamageAssesment.Api.Employees/Db/EmployeeDbContext.cs
2023-09-13 13:16:42 -04:00

27 lines
972 B
C#

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